From 1b23cf58193ae1a2e320e6c6872356ab19c93d22 Mon Sep 17 00:00:00 2001 From: Aikar Date: Mon, 25 May 2020 14:19:11 -0400 Subject: [PATCH] Add missing null check for structure start chunk access Spigot made structure start not load chunks, but forgot to null check the result... This likely never blew up before due to the chunk leak issue, but now that leaky chunks are cleaned up, it was identified. --- .../Unload-leaked-Cached-Chunks.patch | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Spigot-Server-Patches/Unload-leaked-Cached-Chunks.patch b/Spigot-Server-Patches/Unload-leaked-Cached-Chunks.patch index 02f5df65ab..1e28999020 100644 --- a/Spigot-Server-Patches/Unload-leaked-Cached-Chunks.patch +++ b/Spigot-Server-Patches/Unload-leaked-Cached-Chunks.patch @@ -21,6 +21,14 @@ diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/m index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java +++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java +@@ -0,0 +0,0 @@ public class ChunkProviderServer extends IChunkProvider { + } + } + // Paper start ++ if (playerchunk != null) playerchunk.lastActivity = world.getTime(); // Paper + CompletableFuture> future = this.a(playerchunk, l) ? PlayerChunk.UNLOADED_CHUNK_ACCESS_FUTURE : playerchunk.a(chunkstatus, this.playerChunkMap); + if (isUrgent) { + future.thenAccept(either -> this.chunkMapDistance.clearUrgent(chunkcoordintpair)); @@ -0,0 +0,0 @@ public class ChunkProviderServer extends IChunkProvider { if (chunksTicked[0]++ % 10 == 0) this.world.getMinecraftServer().midTickLoadChunks(); // Paper } @@ -104,3 +112,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 PlayerChunk playerchunk = (PlayerChunk) this.updatingChunks.remove(j); if (playerchunk != null) { +diff --git a/src/main/java/net/minecraft/server/StructureGenerator.java b/src/main/java/net/minecraft/server/StructureGenerator.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/StructureGenerator.java ++++ b/src/main/java/net/minecraft/server/StructureGenerator.java +@@ -0,0 +0,0 @@ public abstract class StructureGenerator + while (longiterator.hasNext()) { + long k = longiterator.nextLong(); + IChunkAccess ichunkaccess1 = generatoraccess.getChunkAt(ChunkCoordIntPair.getX(k), ChunkCoordIntPair.getZ(k), ChunkStatus.STRUCTURE_STARTS, false); // CraftBukkit - don't load chunks +- StructureStart structurestart = ichunkaccess1.a(this.b()); ++ StructureStart structurestart = ichunkaccess1 != null ? ichunkaccess1.a(this.b()) : null; // Paper - make sure not null + + if (structurestart != null) { + list.add(structurestart);