From 6dd35a265be71a5404cf966996a6c58d6104df07 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Wed, 6 Dec 2023 12:33:07 +0100 Subject: [PATCH] Fix Tablist Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/tablist/Tablist.java | 16 ++++++---------- .../steamwar/bungeecore/tablist/TablistPart.java | 10 +++++----- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/de/steamwar/bungeecore/tablist/Tablist.java b/src/de/steamwar/bungeecore/tablist/Tablist.java index 07fb382..e5cf7f3 100644 --- a/src/de/steamwar/bungeecore/tablist/Tablist.java +++ b/src/de/steamwar/bungeecore/tablist/Tablist.java @@ -89,8 +89,8 @@ public class Tablist extends MessageToMessageDecoder { if(tabItem == null) { tablist.add(0, item); - } else if(!tabItem.getDisplayName().equals(wrapName(item.getDisplayName()))) { - tabItem.setDisplayName(wrapName(item.getDisplayName())); + } else if(!tabItem.getDisplayName().equals(item.getDisplayName())) { + tabItem.setDisplayName(item.getDisplayName()); tabItem.setListed(true); update.add(tabItem); } @@ -126,13 +126,13 @@ public class Tablist extends MessageToMessageDecoder { TablistPart.Item item = tablist.get(i); if(!Arrays.equals(tabItem.getProperties(), item.getProperties())) { tabItem.setProperties(item.getProperties()); - tabItem.setDisplayName(wrapName(item.getDisplayName())); + tabItem.setDisplayName(item.getDisplayName()); add.add(tabItem); if(current.size() > i) { remove.add(tabItem); } } else if(!item.getDisplayName().equals(tabItem.getDisplayName())) { - tabItem.setDisplayName(wrapName(item.getDisplayName())); + tabItem.setDisplayName(item.getDisplayName()); update.add(tabItem); } } @@ -212,7 +212,7 @@ public class Tablist extends MessageToMessageDecoder { case ADD_PLAYER: for (PlayerListItem.Item item : list.getItems()) { item.setPing(1); - item.setDisplayName(wrapName("")); + item.setDisplayName(new TextComponent()); item.setListed(false); item.setPublicKey(null); if(!player.getUniqueId().equals(item.getUuid()) && item.getGamemode() == 3) @@ -262,7 +262,7 @@ public class Tablist extends MessageToMessageDecoder { case ADD_PLAYER: for (PlayerListItem.Item item : list.getItems()) { item.setPing(1); - item.setDisplayName(wrapName("")); + item.setDisplayName(new TextComponent()); item.setListed(false); item.setPublicKey(null); if(!player.getUniqueId().equals(item.getUuid()) && item.getGamemode() == 3) @@ -304,10 +304,6 @@ public class Tablist extends MessageToMessageDecoder { return player.getPendingConnection().getVersion() < ProtocolConstants.MINECRAFT_1_19_3; } - private BaseComponent wrapName(String name) { - return new TextComponent(name); - } - private void sendTabPacket(List items, PlayerListItem.Action action) { //Breaks in 1.19.3 if action != UPDATE_DISPLAY_NAME, ADD_PLAYER or REMOVE_PLAYER if(!items.isEmpty()) { if(oldTab()) { diff --git a/src/de/steamwar/bungeecore/tablist/TablistPart.java b/src/de/steamwar/bungeecore/tablist/TablistPart.java index 56b8851..f15a239 100644 --- a/src/de/steamwar/bungeecore/tablist/TablistPart.java +++ b/src/de/steamwar/bungeecore/tablist/TablistPart.java @@ -22,9 +22,9 @@ package de.steamwar.bungeecore.tablist; import de.steamwar.messages.ChatSender; import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.UserPerm; +import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.connection.ProxiedPlayer; -import net.md_5.bungee.chat.ComponentSerializer; import net.md_5.bungee.connection.InitialHandler; import net.md_5.bungee.connection.LoginResult; import net.md_5.bungee.protocol.Property; @@ -47,7 +47,7 @@ interface TablistPart { } private final UUID uuid; - private final String displayName; + private final BaseComponent displayName; private final Property[] properties; public Item(UUID uuid, String displayName, Property[] properties) { @@ -75,7 +75,7 @@ interface TablistPart { return uuid; } - public String getDisplayName() { + public BaseComponent getDisplayName() { return displayName; } @@ -83,8 +83,8 @@ interface TablistPart { return properties; } - private String reformat(String string) { - return ComponentSerializer.toString(TextComponent.fromLegacyText(string)); + private BaseComponent reformat(String string) { + return TextComponent.fromArray(TextComponent.fromLegacyText(string)); } } }