From f15eed338d60553708734e47f8ebec9362280d26 Mon Sep 17 00:00:00 2001 From: md_5 Date: Sun, 31 Aug 2014 19:01:24 +1000 Subject: [PATCH] Fix tab list --- protocol/pom.xml | 6 ++++++ .../net/md_5/bungee/protocol/packet/PlayerListItem.java | 4 +++- proxy/src/main/java/net/md_5/bungee/tab/Global.java | 8 +++++--- proxy/src/main/java/net/md_5/bungee/tab/ServerUnique.java | 8 +++++--- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/protocol/pom.xml b/protocol/pom.xml index 545508d5b..0e820c4b8 100644 --- a/protocol/pom.xml +++ b/protocol/pom.xml @@ -19,6 +19,12 @@ Minimal implementation of the Minecraft protocol for use in BungeeCord + + net.md-5 + bungeecord-chat + ${project.version} + compile + io.netty netty-codec diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/PlayerListItem.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/PlayerListItem.java index ea12d6e14..ff5976861 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/PlayerListItem.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/PlayerListItem.java @@ -9,6 +9,8 @@ import net.md_5.bungee.protocol.AbstractPacketHandler; import net.md_5.bungee.protocol.ProtocolConstants; import java.util.UUID; +import net.md_5.bungee.api.chat.TextComponent; +import net.md_5.bungee.chat.ComponentSerializer; @Data @NoArgsConstructor @@ -89,7 +91,7 @@ public class PlayerListItem extends DefinedPacket if ( protocolVersion < ProtocolConstants.MINECRAFT_SNAPSHOT ) { Item item = items[0]; // Only one at a time - writeString( item.displayName, buf ); + writeString( TextComponent.toLegacyText( ComponentSerializer.parse( item.displayName ) ), buf ); buf.writeBoolean( action != Action.REMOVE_PLAYER ); buf.writeShort( item.ping ); } else diff --git a/proxy/src/main/java/net/md_5/bungee/tab/Global.java b/proxy/src/main/java/net/md_5/bungee/tab/Global.java index 30b7cbe57..ecd8ff042 100644 --- a/proxy/src/main/java/net/md_5/bungee/tab/Global.java +++ b/proxy/src/main/java/net/md_5/bungee/tab/Global.java @@ -100,9 +100,11 @@ public class Global extends TabList { PlayerListItem packet = new PlayerListItem(); packet.setAction( playerListItem.getAction() ); - PlayerListItem.Item[] it = new PlayerListItem.Item[ 1 ]; - it[0] = item; - packet.setItems( it ); + + packet.setItems( new PlayerListItem.Item[] + { + item + } ); player.unsafe().sendPacket( packet ); } } diff --git a/proxy/src/main/java/net/md_5/bungee/tab/ServerUnique.java b/proxy/src/main/java/net/md_5/bungee/tab/ServerUnique.java index 9e31b3f7a..60e591434 100644 --- a/proxy/src/main/java/net/md_5/bungee/tab/ServerUnique.java +++ b/proxy/src/main/java/net/md_5/bungee/tab/ServerUnique.java @@ -82,9 +82,11 @@ public class ServerUnique extends TabList { PlayerListItem p2 = new PlayerListItem(); p2.setAction( packet.getAction() ); - PlayerListItem.Item[] it = new PlayerListItem.Item[ 1 ]; - it[0] = item; - p2.setItems( it ); + + p2.setItems( new PlayerListItem.Item[] + { + item + } ); player.unsafe().sendPacket( p2 ); } }