From e33fdd81895ae9fe5beb8ad86c0fe573de9fc314 Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Thu, 22 Feb 2024 16:23:15 +0000 Subject: [PATCH] Do not access world state to see if we can see a Player Thrown into the adventure patch because I don't see the justification of a patch existing for something like this. --- patches/server/Adventure.patch | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/patches/server/Adventure.patch b/patches/server/Adventure.patch index d56513e1c..8b68fa7c1 100644 --- a/patches/server/Adventure.patch +++ b/patches/server/Adventure.patch @@ -3019,6 +3019,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 AsyncPlayerChatEvent event = new AsyncPlayerChatEvent(async, player, s, new LazyPlayerSet(this.server)); String originalFormat = event.getFormat(), originalMessage = event.getMessage(); @@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl + + public void sendPlayerChatMessage(PlayerChatMessage message, ChatType.Bound params) { + // CraftBukkit start - SPIGOT-7262: if hidden we have to send as disguised message. Query whether we should send at all (but changing this may not be expected). +- if (!this.getCraftPlayer().canSee(message.link().sender())) { ++ // Paper start - Do not query the world for players, if they're not in the player list, then they're not in the world - don't query world state ++ // Also, mirror the logic for canSee in terms of "missing" players ++ final ServerPlayer sender = this.server.getPlayerList().getPlayer(message.link().sender()); ++ if (sender == null || !this.getCraftPlayer().canSee(sender.getBukkitEntity())) { ++ // Paper end + this.sendDisguisedChatMessage(message.decoratedContent(), params); + return; + } +@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl public void handleClientInformation(ServerboundClientInformationPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); this.player.updateOptions(packet.information());