diff --git a/paper-server/nms-patches/net/minecraft/server/level/WorldServer.patch b/paper-server/nms-patches/net/minecraft/server/level/WorldServer.patch index 9d04adf939..241087a92a 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/WorldServer.patch +++ b/paper-server/nms-patches/net/minecraft/server/level/WorldServer.patch @@ -592,11 +592,18 @@ } public void onTrackingEnd(Entity entity) { -@@ -1664,6 +1877,7 @@ +@@ -1664,6 +1877,14 @@ gameeventlistenerregistrar.onListenerRemoved(entity.level); } -+ entity.valid = false; // CraftBukkit ++ // CraftBukkit start ++ entity.valid = false; ++ if (!(entity instanceof EntityPlayer)) { ++ for (EntityPlayer player : players) { ++ player.getBukkitEntity().onEntityRemove(entity); ++ } ++ } ++ // CraftBukkit end } } } diff --git a/paper-server/nms-patches/net/minecraft/server/players/PlayerList.patch b/paper-server/nms-patches/net/minecraft/server/players/PlayerList.patch index de71acb351..fd2565a25c 100644 --- a/paper-server/nms-patches/net/minecraft/server/players/PlayerList.patch +++ b/paper-server/nms-patches/net/minecraft/server/players/PlayerList.patch @@ -301,7 +301,7 @@ + if (entityplayer2.getBukkitEntity().canSee(entityplayer.getBukkitEntity())) { + entityplayer2.connection.send(packet); + } else { -+ entityplayer2.getBukkitEntity().removeDisconnectingPlayer(entityplayer.getBukkitEntity()); ++ entityplayer2.getBukkitEntity().onEntityRemove(entityplayer); + } } + // This removes the scoreboard (and player reference) for the specific player in the manager diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 8e422d5d2f..4a8988a96a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -1154,8 +1154,8 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } } - public void removeDisconnectingPlayer(Player player) { - hiddenEntities.remove(player.getUniqueId()); + public void onEntityRemove(Entity entity) { + hiddenEntities.remove(entity.getUUID()); } @Override