--- a/net/minecraft/server/level/ChunkMapDistance.java +++ b/net/minecraft/server/level/ChunkMapDistance.java @@ -77,6 +77,11 @@ } if (!this.chunksToUpdateFutures.isEmpty()) { + // CraftBukkit start - SPIGOT-7780: Call chunk unload events before updateHighestAllowedStatus + for (PlayerChunk playerchunk : this.chunksToUpdateFutures) { + playerchunk.callEventIfUnloading(playerchunkmap); + } + // CraftBukkit end for (PlayerChunk playerchunk : this.chunksToUpdateFutures) { playerchunk.updateHighestAllowedStatus(playerchunkmap); } @@ -137,6 +142,7 @@ ChunkCoordIntPair chunkcoordintpair = sectionposition.chunk(); long i = chunkcoordintpair.toLong(); ObjectSet objectset = (ObjectSet) this.playersPerChunk.get(i); + if (objectset == null) return; // CraftBukkit - SPIGOT-6208 objectset.remove(entityplayer); if (objectset.isEmpty()) {