Archiviert
1
0

Fix Tablist for 1.20.3 Waterfall

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2023-12-06 11:40:34 +01:00
Ursprung 4979889468
Commit 3ea910501a

Datei anzeigen

@ -31,9 +31,9 @@ import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.chat.ComponentSerializer;
import net.md_5.bungee.netty.PipelineUtils; import net.md_5.bungee.netty.PipelineUtils;
import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.DefinedPacket;
import net.md_5.bungee.protocol.Either;
import net.md_5.bungee.protocol.PacketWrapper; import net.md_5.bungee.protocol.PacketWrapper;
import net.md_5.bungee.protocol.ProtocolConstants; import net.md_5.bungee.protocol.ProtocolConstants;
import net.md_5.bungee.protocol.packet.*; import net.md_5.bungee.protocol.packet.*;
@ -48,7 +48,7 @@ public class Tablist extends MessageToMessageDecoder<PacketWrapper> {
private static final UUID[] uuids = IntStream.range(0, 80).mapToObj(i -> UUID.randomUUID()).toArray(UUID[]::new); private static final UUID[] uuids = IntStream.range(0, 80).mapToObj(i -> UUID.randomUUID()).toArray(UUID[]::new);
private static final String[] names = IntStream.range(0, 80).mapToObj(i -> " »SW« " + String.format("%02d", i)).toArray(String[]::new); private static final String[] names = IntStream.range(0, 80).mapToObj(i -> " »SW« " + String.format("%02d", i)).toArray(String[]::new);
private static final String TAB_TEAM = "zzzzzsw-tab"; private static final String TAB_TEAM = "zzzzzsw-tab";
private static final Team teamPacket = new Team(TAB_TEAM, (byte) 0, ComponentSerializer.toString(TextComponent.fromLegacyText("")), ComponentSerializer.toString(TextComponent.fromLegacyText("")), ComponentSerializer.toString(TextComponent.fromLegacyText("")), "never", "always", 21, (byte)0x00, names); private static final Team teamPacket = new Team(TAB_TEAM, (byte) 0, Either.right(TextComponent.fromLegacy("")), Either.right(TextComponent.fromLegacy("")), Either.right(TextComponent.fromLegacy("")), "never", "always", 21, (byte)0x00, names);
private final Map<UUID, PlayerListItem.Item> directTabItems; private final Map<UUID, PlayerListItem.Item> directTabItems;
private final Set<UUID> npcs = new HashSet<>(); private final Set<UUID> npcs = new HashSet<>();
@ -90,7 +90,7 @@ public class Tablist extends MessageToMessageDecoder<PacketWrapper> {
if(tabItem == null) { if(tabItem == null) {
tablist.add(0, item); tablist.add(0, item);
} else if(!tabItem.getDisplayName().equals(item.getDisplayName())) { } else if(!tabItem.getDisplayName().equals(item.getDisplayName())) {
tabItem.setDisplayName(item.getDisplayName()); tabItem.setDisplayName(TextComponent.fromLegacy(item.getDisplayName()));
tabItem.setListed(true); tabItem.setListed(true);
update.add(tabItem); update.add(tabItem);
} }
@ -126,13 +126,13 @@ public class Tablist extends MessageToMessageDecoder<PacketWrapper> {
TablistPart.Item item = tablist.get(i); TablistPart.Item item = tablist.get(i);
if(!Arrays.equals(tabItem.getProperties(), item.getProperties())) { if(!Arrays.equals(tabItem.getProperties(), item.getProperties())) {
tabItem.setProperties(item.getProperties()); tabItem.setProperties(item.getProperties());
tabItem.setDisplayName(item.getDisplayName()); tabItem.setDisplayName(TextComponent.fromLegacy(item.getDisplayName()));
add.add(tabItem); add.add(tabItem);
if(current.size() > i) { if(current.size() > i) {
remove.add(tabItem); remove.add(tabItem);
} }
} else if(!item.getDisplayName().equals(tabItem.getDisplayName())) { } else if(!item.getDisplayName().equals(tabItem.getDisplayName())) {
tabItem.setDisplayName(item.getDisplayName()); tabItem.setDisplayName(TextComponent.fromLegacy(item.getDisplayName()));
update.add(tabItem); update.add(tabItem);
} }
} }
@ -212,7 +212,7 @@ public class Tablist extends MessageToMessageDecoder<PacketWrapper> {
case ADD_PLAYER: case ADD_PLAYER:
for (PlayerListItem.Item item : list.getItems()) { for (PlayerListItem.Item item : list.getItems()) {
item.setPing(1); item.setPing(1);
item.setDisplayName(ComponentSerializer.toString(TextComponent.fromLegacyText(""))); item.setDisplayName(TextComponent.fromLegacy(""));
item.setListed(false); item.setListed(false);
item.setPublicKey(null); item.setPublicKey(null);
if(!player.getUniqueId().equals(item.getUuid()) && item.getGamemode() == 3) if(!player.getUniqueId().equals(item.getUuid()) && item.getGamemode() == 3)
@ -262,7 +262,7 @@ public class Tablist extends MessageToMessageDecoder<PacketWrapper> {
case ADD_PLAYER: case ADD_PLAYER:
for (PlayerListItem.Item item : list.getItems()) { for (PlayerListItem.Item item : list.getItems()) {
item.setPing(1); item.setPing(1);
item.setDisplayName(ComponentSerializer.toString(TextComponent.fromLegacyText(""))); item.setDisplayName(TextComponent.fromLegacy(""));
item.setListed(false); item.setListed(false);
item.setPublicKey(null); item.setPublicKey(null);
if(!player.getUniqueId().equals(item.getUuid()) && item.getGamemode() == 3) if(!player.getUniqueId().equals(item.getUuid()) && item.getGamemode() == 3)