From c204872eb471ae839e293d0db6669b1df87cbe8e Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Tue, 2 Jul 2019 19:50:03 +0100 Subject: [PATCH] use a Queue in ChunkMapDistance An oversight in this patch may be to blame for several issues in certain cases, we'll opt to using a queue as this will fall in line with what is expected and may help some issues where chunks remain loaded or fail to load --- .../Chunk-debug-command.patch | 2 +- .../ChunkMapDistance-CME.patch | 34 ++++++++++++------- Spigot-Server-Patches/Fix-MC-154214.patch | 2 +- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/Spigot-Server-Patches/Chunk-debug-command.patch b/Spigot-Server-Patches/Chunk-debug-command.patch index 30a35e0a0a..7bfbb25758 100644 --- a/Spigot-Server-Patches/Chunk-debug-command.patch +++ b/Spigot-Server-Patches/Chunk-debug-command.patch @@ -185,7 +185,7 @@ index 391726d99c..8db92edc36 100644 * Ported from MinecraftForge - author: LexManos - License: LGPLv2.1 */ diff --git a/src/main/java/net/minecraft/server/ChunkMapDistance.java b/src/main/java/net/minecraft/server/ChunkMapDistance.java -index cd18150488..0c562a5f34 100644 +index f72843119a..c1fdd7b7a4 100644 --- a/src/main/java/net/minecraft/server/ChunkMapDistance.java +++ b/src/main/java/net/minecraft/server/ChunkMapDistance.java @@ -0,0 +0,0 @@ public abstract class ChunkMapDistance { diff --git a/Spigot-Server-Patches/ChunkMapDistance-CME.patch b/Spigot-Server-Patches/ChunkMapDistance-CME.patch index a022123cab..c81cd5361f 100644 --- a/Spigot-Server-Patches/ChunkMapDistance-CME.patch +++ b/Spigot-Server-Patches/ChunkMapDistance-CME.patch @@ -5,15 +5,23 @@ Subject: [PATCH] ChunkMapDistance CME diff --git a/src/main/java/net/minecraft/server/ChunkMapDistance.java b/src/main/java/net/minecraft/server/ChunkMapDistance.java -index ed4e8d69ca..cd18150488 100644 +index ed4e8d69ca..f72843119a 100644 --- a/src/main/java/net/minecraft/server/ChunkMapDistance.java +++ b/src/main/java/net/minecraft/server/ChunkMapDistance.java +@@ -0,0 +0,0 @@ import it.unimi.dsi.fastutil.objects.ObjectSortedSet; + import java.util.Set; + import java.util.concurrent.CompletableFuture; + import java.util.concurrent.Executor; ++ + import javax.annotation.Nullable; + import org.apache.logging.log4j.LogManager; + import org.apache.logging.log4j.Logger; @@ -0,0 +0,0 @@ public abstract class ChunkMapDistance { private final ChunkMapDistance.a e = new ChunkMapDistance.a(); private final ChunkMapDistance.b f = new ChunkMapDistance.b(8); private final ChunkMapDistance.c g = new ChunkMapDistance.c(33); - private final Set h = Sets.newHashSet(); -+ private Set h = Sets.newHashSet(); // Paper - -final ++ private java.util.Queue h = new java.util.LinkedList<>(); // Paper - -final private final PlayerChunk.c i; private final Mailbox> j; private final Mailbox k; @@ -21,15 +29,17 @@ index ed4e8d69ca..cd18150488 100644 ; } -- if (!this.h.isEmpty()) { -- this.h.forEach((playerchunk) -> { + // Paper start -+ Set currentPending = this.h; -+ this.h = Sets.newHashSet(); -+ if (!currentPending.isEmpty()) { -+ currentPending.forEach((playerchunk) -> { -+ // Paper end - playerchunk.a(playerchunkmap); - }); - this.h.clear(); + if (!this.h.isEmpty()) { +- this.h.forEach((playerchunk) -> { +- playerchunk.a(playerchunkmap); +- }); +- this.h.clear(); ++ while(!this.h.isEmpty()) { ++ this.h.remove().a(playerchunkmap); ++ } ++ // Paper end + return true; + } else { + if (!this.l.isEmpty()) { -- \ No newline at end of file diff --git a/Spigot-Server-Patches/Fix-MC-154214.patch b/Spigot-Server-Patches/Fix-MC-154214.patch index caebf2a89f..6621f4277d 100644 --- a/Spigot-Server-Patches/Fix-MC-154214.patch +++ b/Spigot-Server-Patches/Fix-MC-154214.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Fix MC-154214 Avoid adding player tickets when they're out of range of the closest player diff --git a/src/main/java/net/minecraft/server/ChunkMapDistance.java b/src/main/java/net/minecraft/server/ChunkMapDistance.java -index 0c562a5f34..7a76db08fc 100644 +index c1fdd7b7a4..1a6fe87cd8 100644 --- a/src/main/java/net/minecraft/server/ChunkMapDistance.java +++ b/src/main/java/net/minecraft/server/ChunkMapDistance.java @@ -0,0 +0,0 @@ public abstract class ChunkMapDistance {