diff --git a/Spigot-Server-Patches/Anti-Xray.patch b/Spigot-Server-Patches/Anti-Xray.patch index bf5c36b428..43127f2463 100644 --- a/Spigot-Server-Patches/Anti-Xray.patch +++ b/Spigot-Server-Patches/Anti-Xray.patch @@ -1071,7 +1071,7 @@ index 56c3783412..f3d9211baa 100644 this.initLighting(); } diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java -index 90e6de419e..538e4b04d9 100644 +index 93bc613958..31faeb43f6 100644 --- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java +++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java @@ -0,0 +0,0 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver { diff --git a/Spigot-Server-Patches/Chunk-Save-Stats-Debug-Option.patch b/Spigot-Server-Patches/Chunk-Save-Stats-Debug-Option.patch index c803ec929c..78dc6e22cd 100644 --- a/Spigot-Server-Patches/Chunk-Save-Stats-Debug-Option.patch +++ b/Spigot-Server-Patches/Chunk-Save-Stats-Debug-Option.patch @@ -54,7 +54,7 @@ index 87744dcbfc..355186c111 100644 return false; } diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java -index 3283b5047d..110c9ef520 100644 +index 2415404d69..f099b91f7a 100644 --- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java +++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java @@ -0,0 +0,0 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver { @@ -77,11 +77,11 @@ index 3283b5047d..110c9ef520 100644 protected void a(ChunkCoordIntPair chunkcoordintpair, Supplier nbttagcompound) { // Spigot + queuedSaves++; // Paper - synchronized (this.queue) { // Paper - synchronize while modifying the map + synchronized (this.b) { // Paper - synchronize while modifying the map queue.add(new QueuedChunk(chunkcoordintpair, nbttagcompound)); // Paper - Chunk queue improvements this.b.put(chunkcoordintpair, nbttagcompound); @@ -0,0 +0,0 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver { - } else { + // Paper end ChunkCoordIntPair chunkcoordintpair = chunk.coords; // Paper - Chunk queue improvements Supplier nbttagcompound = chunk.compoundSupplier; // Spigot // Paper + processedSaves.incrementAndGet(); // Paper diff --git a/Spigot-Server-Patches/Chunk-save-queue-improvements.patch b/Spigot-Server-Patches/Chunk-save-queue-improvements.patch index a52a0716f5..eb84bff62f 100644 --- a/Spigot-Server-Patches/Chunk-save-queue-improvements.patch +++ b/Spigot-Server-Patches/Chunk-save-queue-improvements.patch @@ -41,7 +41,7 @@ index 0d68ffd75a..fd00c320ce 100644 + } } diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java -index 2e9bd0949a..3166d4b1ad 100644 +index 2e9bd0949a..1dbcedbf94 100644 --- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java +++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java @@ -0,0 +0,0 @@ import java.util.function.Consumer; @@ -60,6 +60,13 @@ index 2e9bd0949a..3166d4b1ad 100644 + private static class QueuedChunk { + public ChunkCoordIntPair coords; + public Supplier compoundSupplier; ++ public Runnable onSave; ++ ++ public QueuedChunk(Runnable run) { ++ this.coords = null; ++ this.compoundSupplier = null; ++ this.onSave = run; ++ } + + public QueuedChunk(ChunkCoordIntPair coords, Supplier compoundSupplier) { + this.coords = coords; @@ -88,7 +95,7 @@ index 2e9bd0949a..3166d4b1ad 100644 protected void a(ChunkCoordIntPair chunkcoordintpair, Supplier nbttagcompound) { // Spigot - this.b.put(chunkcoordintpair, nbttagcompound); -+ synchronized (this.queue) { // Paper - synchronize while modifying the map ++ synchronized (this.b) { // Paper - synchronize while modifying the map + queue.add(new QueuedChunk(chunkcoordintpair, nbttagcompound)); // Paper - Chunk queue improvements + this.b.put(chunkcoordintpair, nbttagcompound); + } @@ -117,6 +124,12 @@ index 2e9bd0949a..3166d4b1ad 100644 - iterator.remove(); - ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair) entry.getKey(); - Supplier nbttagcompound = (Supplier) entry.getValue(); // Spigot ++ // Paper start ++ if (chunk.onSave != null) { ++ chunk.onSave.run(); ++ return true; ++ } ++ // Paper end + ChunkCoordIntPair chunkcoordintpair = chunk.coords; // Paper - Chunk queue improvements + Supplier nbttagcompound = chunk.compoundSupplier; // Spigot // Paper @@ -127,7 +140,7 @@ index 2e9bd0949a..3166d4b1ad 100644 RegionFileCache.write(this.c, chunkcoordintpair.x, chunkcoordintpair.z, SupplierUtils.getIfExists(nbttagcompound)); // Spigot + // Paper start remove from map only if this was the latest version of the chunk -+ synchronized (this.queue) { ++ synchronized (this.b) { + // This will not equal if a newer version is still pending - wait until newest is saved to remove + if (this.b.get(chunkcoordintpair) == chunk.compoundSupplier) { + this.b.remove(chunkcoordintpair); @@ -137,6 +150,15 @@ index 2e9bd0949a..3166d4b1ad 100644 /* NBTCompressedStreamTools.a(nbttagcompound, (DataOutput) dataoutputstream); dataoutputstream.close(); +@@ -0,0 +0,0 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver { + return true; + } + } +- } // CraftBukkit ++ // } // CraftBukkit // Paper + } + + private ChunkStatus.Type a(@Nullable NBTTagCompound nbttagcompound) { diff --git a/src/main/java/net/minecraft/server/FileIOThread.java b/src/main/java/net/minecraft/server/FileIOThread.java index a3aba244af..97917551a4 100644 --- a/src/main/java/net/minecraft/server/FileIOThread.java diff --git a/Spigot-Server-Patches/Don-t-save-Proto-Chunks.patch b/Spigot-Server-Patches/Don-t-save-Proto-Chunks.patch index 21318e04d7..f5aa3deaa3 100644 --- a/Spigot-Server-Patches/Don-t-save-Proto-Chunks.patch +++ b/Spigot-Server-Patches/Don-t-save-Proto-Chunks.patch @@ -8,7 +8,7 @@ the loadChunk method refuses to acknoledge they exists, and will restart a new chunk generation process to begin with, so saving them serves no benefit. diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java -index 110c9ef520..3074aa50e8 100644 +index f099b91f7a..ec94b9fe57 100644 --- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java +++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java @@ -0,0 +0,0 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver { diff --git a/Spigot-Server-Patches/Fix-Double-World-Add-issues.patch b/Spigot-Server-Patches/Fix-Double-World-Add-issues.patch index 1ef7016a63..8bb577624c 100644 --- a/Spigot-Server-Patches/Fix-Double-World-Add-issues.patch +++ b/Spigot-Server-Patches/Fix-Double-World-Add-issues.patch @@ -8,7 +8,7 @@ Vanilla will double add Spider Jockeys to the world, so ignore already added. Also add debug if something else tries to, and abort before world gets bad state diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java -index 3166d4b1ad..1c5b7903cc 100644 +index 1dbcedbf94..8e14f8c56c 100644 --- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java +++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java @@ -0,0 +0,0 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver { diff --git a/Spigot-Server-Patches/Prevent-Auto-Save-if-Save-Queue-is-full.patch b/Spigot-Server-Patches/Prevent-Auto-Save-if-Save-Queue-is-full.patch index 363ad1a187..b2db05afb5 100644 --- a/Spigot-Server-Patches/Prevent-Auto-Save-if-Save-Queue-is-full.patch +++ b/Spigot-Server-Patches/Prevent-Auto-Save-if-Save-Queue-is-full.patch @@ -41,7 +41,7 @@ index 7a972f4187..87744dcbfc 100644 Chunk chunk = (Chunk) objectiterator.next(); diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java -index fde80d1fd3..3283b5047d 100644 +index 8e14f8c56c..2415404d69 100644 --- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java +++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java @@ -0,0 +0,0 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver { diff --git a/Spigot-Server-Patches/Prevent-Saving-Bad-entities-to-chunks.patch b/Spigot-Server-Patches/Prevent-Saving-Bad-entities-to-chunks.patch index 2ff1fc1745..2cacd917f5 100644 --- a/Spigot-Server-Patches/Prevent-Saving-Bad-entities-to-chunks.patch +++ b/Spigot-Server-Patches/Prevent-Saving-Bad-entities-to-chunks.patch @@ -18,7 +18,7 @@ an invalid entity. This should reduce log occurrences of dupe uuid messages. diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java -index 4f0571ae26..b0fa23db5e 100644 +index ec94b9fe57..e6ede2cc25 100644 --- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java +++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java @@ -0,0 +0,0 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver { diff --git a/Spigot-Server-Patches/Provide-option-to-use-a-versioned-world-folder-for-t.patch b/Spigot-Server-Patches/Provide-option-to-use-a-versioned-world-folder-for-t.patch index 35bdd5930e..a2f84f95f5 100644 --- a/Spigot-Server-Patches/Provide-option-to-use-a-versioned-world-folder-for-t.patch +++ b/Spigot-Server-Patches/Provide-option-to-use-a-versioned-world-folder-for-t.patch @@ -59,7 +59,7 @@ index bcdf4f91d8..c457d07110 100644 + } } diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java -index ffa94ea674..68a3169c31 100644 +index e6ede2cc25..93bc613958 100644 --- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java +++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java @@ -0,0 +0,0 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {