From d6ca2dd32639da07e9b749a784833db38dd23b32 Mon Sep 17 00:00:00 2001 From: Zach Brown <1254957+zachbr@users.noreply.github.com> Date: Fri, 5 Dec 2014 21:33:40 -0600 Subject: [PATCH] Update from upstream SpigotMC 72d33338f08 2a70ece9ab2 [M] abcf7aa4a40 9a88a38258c [M] 8dc4297e34f --- CraftBukkit-Patches/0001-POM-Changes.patch | 12 ++-- .../0015-Entity-Activation-Range.patch | 13 ++++ .../0071-Improve-AutoSave-Mechanism.patch | 72 +++++++++++++++++++ .../0071-Replace-AutoSave-Mechanism.patch | 30 -------- 4 files changed, 90 insertions(+), 37 deletions(-) create mode 100644 CraftBukkit-Patches/0071-Improve-AutoSave-Mechanism.patch delete mode 100644 CraftBukkit-Patches/0071-Replace-AutoSave-Mechanism.patch diff --git a/CraftBukkit-Patches/0001-POM-Changes.patch b/CraftBukkit-Patches/0001-POM-Changes.patch index 3eb21420b..4dcbd09d3 100644 --- a/CraftBukkit-Patches/0001-POM-Changes.patch +++ b/CraftBukkit-Patches/0001-POM-Changes.patch @@ -61,16 +61,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 com.lukegb.mojo gitdescribe-maven-plugin -- 1.3 -+ 2.0 + 2.0 - ${buildtag.prefix} - ${buildtag.suffix} -- -+ -+ --always -+ -+ + + --always + + + ex-spigot diff --git a/CraftBukkit-Patches/0015-Entity-Activation-Range.patch b/CraftBukkit-Patches/0015-Entity-Activation-Range.patch index 7d2ceb5d5..934118606 100644 --- a/CraftBukkit-Patches/0015-Entity-Activation-Range.patch +++ b/CraftBukkit-Patches/0015-Entity-Activation-Range.patch @@ -21,6 +21,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public int noDamageTicks; protected boolean justCreated; protected boolean fireProof; + protected DataWatcher datawatcher; + private double ap; + private double aq; +- public boolean ad; ++ public boolean ad;public boolean isAddedToChunk() { return ad; } // Spigot + public int ae; + public int af; + public int ag; @@ -0,0 +0,0 @@ public abstract class Entity implements ICommandListener { public boolean valid; // CraftBukkit public org.bukkit.projectiles.ProjectileSource projectileSource; // CraftBukkit - For projectiles only @@ -447,6 +455,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public static boolean checkIfActive(Entity entity) + { + SpigotTimings.checkIfActiveTimer.startTiming(); ++ if ( !entity.isAddedToChunk() ) { ++ SpigotTimings.checkIfActiveTimer.stopTiming(); ++ return true; ++ } ++ + boolean isActive = entity.activatedTick >= MinecraftServer.currentTick || entity.defaultActivationState; + + // Should this entity tick? diff --git a/CraftBukkit-Patches/0071-Improve-AutoSave-Mechanism.patch b/CraftBukkit-Patches/0071-Improve-AutoSave-Mechanism.patch new file mode 100644 index 000000000..21aab4bc8 --- /dev/null +++ b/CraftBukkit-Patches/0071-Improve-AutoSave-Mechanism.patch @@ -0,0 +1,72 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: md_5 +Date: Sun, 12 Jan 2014 21:07:18 +1100 +Subject: [PATCH] Improve AutoSave Mechanism + +The problem here is that MinecraftServer.save(..), will attempt to sleep whilst all pending chunks are written to disk. +however due to various and complicated bugs, it will wait for an incorrect amount of chunks, which may cause it to sleep for an overly long amount of time. + +Instead we will mimic the save-all command in its behaviour, which is both safe and performant. + +Also, 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/Chunk.java ++++ b/src/main/java/net/minecraft/server/Chunk.java +@@ -0,0 +0,0 @@ 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() >= this.lastSaved + MinecraftServer.getServer().autosavePeriod * 4) { // Spigot - 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/MinecraftServer.java ++++ b/src/main/java/net/minecraft/server/MinecraftServer.java +@@ -0,0 +0,0 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs + SpigotTimings.worldSaveTimer.startTiming(); // Spigot + this.methodProfiler.a("save"); + this.v.savePlayers(); +- this.saveChunks(true); ++ // 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 ++ server.playerCommandState = true; ++ for (World world : worlds) { ++ world.getWorld().save(false); ++ } ++ server.playerCommandState = false; ++ // this.saveChunks(true); ++ // Spigot End + this.methodProfiler.b(); + SpigotTimings.worldSaveTimer.stopTiming(); // Spigot + } +diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java ++++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +@@ -0,0 +0,0 @@ public class CraftWorld implements World { + } + + public void save() { ++ // Spigot start ++ save(true); ++ } ++ public void save(boolean forceSave) { ++ // Spigot end + this.server.checkSaveState(); + try { + boolean oldSave = world.savingDisabled; + + world.savingDisabled = false; +- world.save(true, null); ++ world.save(forceSave, null); // Spigot + + world.savingDisabled = oldSave; + } catch (ExceptionWorldConflict ex) { +-- \ No newline at end of file diff --git a/CraftBukkit-Patches/0071-Replace-AutoSave-Mechanism.patch b/CraftBukkit-Patches/0071-Replace-AutoSave-Mechanism.patch deleted file mode 100644 index 2e6d7b93e..000000000 --- a/CraftBukkit-Patches/0071-Replace-AutoSave-Mechanism.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: md_5 -Date: Sun, 12 Jan 2014 21:07:18 +1100 -Subject: [PATCH] Replace AutoSave Mechanism - -The problem here is that MinecraftServer.save(..), will attempt to sleep whilst all pending chunks are written to disk, however due to various and complicated bugs, it will wait for an incorrect amount of chunks, which may cause it to sleep for an overly long amount of time. Instead we will mimic the save-all command in its behaviour, which is both safe and performant. - -diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/server/MinecraftServer.java -+++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -0,0 +0,0 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs - SpigotTimings.worldSaveTimer.startTiming(); // Spigot - this.methodProfiler.a("save"); - this.v.savePlayers(); -- this.saveChunks(true); -+ // 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 -+ server.playerCommandState = true; -+ for (World world : worlds) { -+ world.getWorld().save(); -+ } -+ server.playerCommandState = false; -+ // this.saveChunks(true); -+ // Spigot End - this.methodProfiler.b(); - SpigotTimings.worldSaveTimer.stopTiming(); // Spigot - } --- \ No newline at end of file