aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0401-Don-t-crash-if-player-is-attempted-to-be-removed-fro.patch
blob: fe3a5aca21a9286ad80839732a59a8d82fe06a59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 18 Apr 2020 15:59:41 -0400
Subject: [PATCH] Don't crash if player is attempted to be removed from
 untracked chunk.

I suspect it deals with teleporting as it uses players current x/y/z

diff --git a/src/main/java/net/minecraft/server/level/DistanceManager.java b/src/main/java/net/minecraft/server/level/DistanceManager.java
index 8376439e36f0f75779d0fbefbe50b215a40c42aa..4a9d0fca55b71f817defcb4286154c0a47bede03 100644
--- a/src/main/java/net/minecraft/server/level/DistanceManager.java
+++ b/src/main/java/net/minecraft/server/level/DistanceManager.java
@@ -300,8 +300,8 @@ public abstract class DistanceManager {
         ObjectSet<ServerPlayer> objectset = (ObjectSet) this.playersPerChunk.get(i);
         if (objectset == null) return; // CraftBukkit - SPIGOT-6208
 
-        objectset.remove(player);
-        if (objectset.isEmpty()) {
+        if (objectset != null) objectset.remove(player); // Paper - some state corruption happens here, don't crash, clean up gracefully.
+        if (objectset == null || objectset.isEmpty()) { // Paper
             this.playersPerChunk.remove(i);
             this.naturalSpawnChunkCounter.update(i, Integer.MAX_VALUE, false);
             this.playerTicketManager.update(i, Integer.MAX_VALUE, false);