From e99a9b5e4a507e0f695561d445ad545c504dbcab Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Sun, 15 Dec 2024 13:05:35 +0100 Subject: [PATCH] Remove cb null check --- .../minecraft/server/level/DistanceManager.java.patch | 11 +++++++---- .../server/level/ServerChunkCache.java.patch | 10 +++++----- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/server/level/DistanceManager.java.patch b/paper-server/patches/sources/net/minecraft/server/level/DistanceManager.java.patch index 0626bbca7a..f2b1b6a10a 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/DistanceManager.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/DistanceManager.java.patch @@ -78,15 +78,18 @@ } private SortedArraySet> getTickets(long chunkPos) { -@@ -217,8 +_,9 @@ +@@ -217,8 +_,12 @@ ChunkPos chunkPos = sectionPos.chunk(); long packedChunkPos = chunkPos.toLong(); ObjectSet set = this.playersPerChunk.get(packedChunkPos); - set.remove(player); - if (set.isEmpty()) { -+ if (set == null) return; // CraftBukkit - SPIGOT-6208 -+ if (set != null) set.remove(player); // Paper - some state corruption happens here, don't crash, clean up gracefully -+ if (set == null || set.isEmpty()) { // Paper ++ // Paper start - some state corruption happens here, don't crash, clean up gracefully ++ if (set != null) { ++ set.remove(player); ++ } ++ if (set == null || set.isEmpty()) { ++ // Paper end - some state corruption happens here, don't crash, clean up gracefully this.playersPerChunk.remove(packedChunkPos); this.naturalSpawnChunkCounter.update(packedChunkPos, Integer.MAX_VALUE, false); this.playerTicketManager.update(packedChunkPos, Integer.MAX_VALUE, false); diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerChunkCache.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerChunkCache.java.patch index 7d5ee65f78..725c75ec09 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerChunkCache.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerChunkCache.java.patch @@ -131,11 +131,12 @@ boolean flag = this.distanceManager.runAllUpdates(this.chunkMap); boolean flag1 = this.chunkMap.promoteChunkMap(); this.chunkMap.runGenerationTasks(); -@@ -315,17 +_,38 @@ +@@ -315,17 +_,39 @@ @Override public void close() throws IOException { - this.save(true); ++ // CraftBukkit start + this.close(true); + } + @@ -209,13 +210,12 @@ @Override public void setSpawnSettings(boolean spawnSettings) { -- this.spawnEnemies = spawnSettings; -- this.spawnFriendlies = this.spawnFriendlies; + // CraftBukkit start + this.setSpawnSettings(spawnSettings, this.spawnFriendlies); + } -+ public void setSpawnSettings(boolean spawnEnemies, boolean spawnFriendlies) { -+ this.spawnEnemies = spawnEnemies; ++ public void setSpawnSettings(boolean spawnSettings, boolean spawnFriendlies) { + this.spawnEnemies = spawnSettings; +- this.spawnFriendlies = this.spawnFriendlies; + this.spawnFriendlies = spawnFriendlies; + // CraftBukkit end }