Archiviert
13
0
Dieses Repository wurde am 2024-12-25 archiviert. Du kannst Dateien ansehen und es klonen, aber nicht pushen oder Issues/Pull-Requests öffnen.
Paper-Old/Spigot-Server-Patches/0037-Improve-autosave-mechanism.patch
2014-12-03 18:15:12 -06:00

64 Zeilen
2.7 KiB
Diff

From 3a8b7719afd3d7a3301e1ef828dc15fdbff40023 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Fri, 28 Nov 2014 13:47:24 -0600
Subject: [PATCH] Improve autosave mechanism
Only save modified chunks, or chunks with entities after 4 auto save passes
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 949fa96..881e963 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -927,7 +927,7 @@ public class Chunk {
if (this.r && this.world.getTime() != this.lastSaved || this.q) {
return true;
}
- } else if (this.r && this.world.getTime() >= this.lastSaved + 600L) {
+ } else if (this.r && this.world.getTime() >= + MinecraftServer.getServer().autosavePeriod * 4) { // PaperSpigot - Only save if we've passed 2 auto save intervals without modification
return true;
}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index e9f3458..e3c5754 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -694,9 +694,10 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
// Spigot Start
// We replace this with saving each individual world as this.saveChunks(...) is broken,
// and causes the main thread to sleep for random amounts of time depending on chunk activity
+ // Also pass flag to only save modified chunks -- PaperSpigot
server.playerCommandState = true;
for (World world : worlds) {
- world.getWorld().save();
+ world.getWorld().save(true);
}
server.playerCommandState = false;
// this.saveChunks(true);
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 62f6328..91e6aed 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -688,12 +688,18 @@ public class CraftWorld implements World {
}
public void save() {
+ // PaperSpigot start - Improved autosave
+ save(true);
+ }
+
+ public void save(boolean forceSave) {
+ // PaperSpigot end
this.server.checkSaveState();
try {
boolean oldSave = world.savingDisabled;
world.savingDisabled = false;
- world.save(true, null);
+ world.save(forceSave, null);
world.savingDisabled = oldSave;
} catch (ExceptionWorldConflict ex) {
--
1.9.1