From ab63e7e64f3534da85e20b8ab908bd6c41895210 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Sat, 20 Apr 2024 15:24:42 +0200 Subject: [PATCH] Allow setting player list name early --- patches/server/Adventure.patch | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/patches/server/Adventure.patch b/patches/server/Adventure.patch index bab4ef08f7..8184c67481 100644 --- a/patches/server/Adventure.patch +++ b/patches/server/Adventure.patch @@ -3997,6 +3997,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Override + public void playerListName(net.kyori.adventure.text.Component name) { + getHandle().listName = name == null ? null : io.papermc.paper.adventure.PaperAdventure.asVanilla(name); ++ if (getHandle().connection == null) return; // Updates are possible before the player has fully joined + for (ServerPlayer player : server.getHandle().players) { + if (player.getBukkitEntity().canSee(this)) { + player.connection.send(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_DISPLAY_NAME, getHandle())); @@ -4019,6 +4020,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public String getPlayerListName() { return this.getHandle().listName == null ? this.getName() : CraftChatMessage.fromComponent(this.getHandle().listName); +@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + name = this.getName(); + } + this.getHandle().listName = name.equals(this.getName()) ? null : CraftChatMessage.fromStringOrNull(name); ++ if (this.getHandle().connection == null) return; // Paper - Updates are possible before the player has fully joined + for (ServerPlayer player : (List) this.server.getHandle().players) { + if (player.getBukkitEntity().canSee(this)) { + player.connection.send(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_DISPLAY_NAME, this.getHandle())); @@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } }