Nassim Jahnke f00727c57e
1.21.5
Co-authored-by: Bjarne Koll <git@lynxplay.dev>
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
Co-authored-by: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com>
Co-authored-by: MiniDigger | Martin <admin@minidigger.dev>
Co-authored-by: Nassim Jahnke <nassim@njahnke.dev>
Co-authored-by: Noah van der Aa <ndvdaa@gmail.com>
Co-authored-by: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
Co-authored-by: Shane Freeder <theboyetronic@gmail.com>
Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com>
Co-authored-by: Tamion <70228790+notTamion@users.noreply.github.com>
Co-authored-by: Warrior <50800980+Warriorrrr@users.noreply.github.com>
2025-04-12 17:27:00 +02:00

29 lines
1.5 KiB
Diff

--- a/net/minecraft/server/level/DistanceManager.java
+++ b/net/minecraft/server/level/DistanceManager.java
@@ -72,6 +_,12 @@
}
if (!this.chunksToUpdateFutures.isEmpty()) {
+ // CraftBukkit start - SPIGOT-7780: Call chunk unload events before updateHighestAllowedStatus
+ for (final ChunkHolder chunkHolder : this.chunksToUpdateFutures) {
+ chunkHolder.callEventIfUnloading(chunkMap);
+ }
+ // CraftBukkit end - SPIGOT-7780: Call chunk unload events before updateHighestAllowedStatus
+
for (ChunkHolder chunkHolder : this.chunksToUpdateFutures) {
chunkHolder.updateHighestAllowedStatus(chunkMap);
}
@@ -121,8 +_,10 @@
ChunkPos chunkPos = sectionPos.chunk();
long packedChunkPos = chunkPos.toLong();
ObjectSet<ServerPlayer> set = this.playersPerChunk.get(packedChunkPos);
- set.remove(player);
- if (set.isEmpty()) {
+ // 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);