Improve autosave

- don't trip manual save warning
- respect world#isSavingDisabled
This commit is contained in:
Shane Freeder 2019-06-10 06:39:04 +01:00
parent 60aa918c76
commit eba1fb2247
No known key found for this signature in database
GPG key ID: A3F61EA5A085289C

View file

@ -1,4 +1,4 @@
From c5851b2a5288702fd63f5ab5d199868ab6222d48 Mon Sep 17 00:00:00 2001
From 82e112148beccdfbb3079008b4e56ee029a17048 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Sun, 9 Jun 2019 03:53:22 +0100
Subject: [PATCH] incremental chunk saving
@ -42,7 +42,7 @@ index ef07f665b7..d89ad4e390 100644
private long t;
@Nullable
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 184f1b00f0..13e862aa9f 100644
index 184f1b00f0..3dbe83c7ea 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -156,6 +156,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@ -53,7 +53,7 @@ index 184f1b00f0..13e862aa9f 100644
public File bukkitDataPackFolder;
public CommandDispatcher vanillaCommandDispatcher;
private boolean forceTicks;
@@ -1072,14 +1073,22 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -1072,14 +1073,28 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
this.serverPing.b().a(agameprofile);
}
@ -67,8 +67,14 @@ index 184f1b00f0..13e862aa9f 100644
- this.saveChunks(true, false, false);
+ }// Paper
+ // Paper start
+ for (World world : getWorlds()) {
+ if (world.paperConfig.autoSavePeriod > 0) world.getWorld().save(false);
+ for (WorldServer world : getWorlds()) {
+ if (world.paperConfig.autoSavePeriod > 0) {
+ try {
+ world.save(null, false, world.isSavingDisabled());
+ } catch (ExceptionWorldConflict exceptionWorldConflict) {
+ MinecraftServer.LOGGER.warn(exceptionWorldConflict.getMessage());
+ }
+ }
+ }
+ // Paper end
+
@ -137,31 +143,6 @@ index 92aad060ef..c650f40b0d 100644
timings.worldSaveChunks.startTiming(); // Paper
chunkproviderserver.save(flag);
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 0c53795306..4e60931cd8 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -1151,13 +1151,19 @@ public class CraftWorld implements World {
// Paper end
@Override
+ // Paper start
public void save() {
+ save(true);
+ }
+
+ public void save(boolean forceSave) {
+ // Paper end
this.server.checkSaveState();
try {
boolean oldSave = world.savingDisabled;
world.savingDisabled = false;
- world.save(null, false, false);
+ world.save(null, forceSave, false); // Paper
world.savingDisabled = oldSave;
} catch (ExceptionWorldConflict ex) {
--
2.21.0