From e35f7e101b24d780680e0de78dcd4dc35fe2daf5 Mon Sep 17 00:00:00 2001 From: Florian Stober Date: Sat, 21 Oct 2023 10:28:13 +0200 Subject: [PATCH 01/10] check whether connection is active in BukkitBridge --- .../codecrafter47/bungeetablistplus/bridge/BukkitBridge.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bungee/src/main/java/codecrafter47/bungeetablistplus/bridge/BukkitBridge.java b/bungee/src/main/java/codecrafter47/bungeetablistplus/bridge/BukkitBridge.java index b053990a..f77dbab0 100644 --- a/bungee/src/main/java/codecrafter47/bungeetablistplus/bridge/BukkitBridge.java +++ b/bungee/src/main/java/codecrafter47/bungeetablistplus/bridge/BukkitBridge.java @@ -572,7 +572,7 @@ protected void addActiveKey(DataKey key) { try { synchronized (this) { Server connection = getConnection(); - if (connection != null) { + if (connection != null && connection.isConnected()) { if (!requestedDataKeys.contains(key)) { requestedDataKeys.add(key); ByteArrayDataOutput data = ByteStreams.newDataOutput(); From 5a02b476042b296a78be2650cd542bc34e67423c Mon Sep 17 00:00:00 2001 From: Florian Stober Date: Sat, 21 Oct 2023 12:21:21 +0200 Subject: [PATCH 02/10] after server switch delay updating tab list until receiving tab list packets from the server; see #731 --- .../handler/NewTabOverlayHandler.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/bungee/src/main/java/codecrafter47/bungeetablistplus/handler/NewTabOverlayHandler.java b/bungee/src/main/java/codecrafter47/bungeetablistplus/handler/NewTabOverlayHandler.java index 50fea221..ffeef845 100644 --- a/bungee/src/main/java/codecrafter47/bungeetablistplus/handler/NewTabOverlayHandler.java +++ b/bungee/src/main/java/codecrafter47/bungeetablistplus/handler/NewTabOverlayHandler.java @@ -205,6 +205,12 @@ public PacketListenerResult onPlayerListPacket(PlayerListItem packet) { @Override public PacketListenerResult onPlayerListUpdatePacket(PlayerListItemUpdate packet) { + + if (!active) { + active = true; + scheduleUpdate(); + } + if (packet.getActions().contains(PlayerListItemUpdate.Action.ADD_PLAYER)) { for (PlayerListItem.Item item : packet.getItems()) { if (OPTION_ENABLE_CUSTOM_SLOT_UUID_COLLISION_CHECK) { @@ -298,6 +304,8 @@ public void onServerSwitch(boolean is13OrLater) { if (serverFooter != null) { serverFooter = EMPTY_JSON_TEXT; } + + active = false; } @Override @@ -345,7 +353,7 @@ private void update() { updateScheduledFlag.set(false); ChannelWrapper ch = ((UserConnection) player).getCh(); - if (ch.isClosed() || ch.getEncodeProtocol() != Protocol.GAME) { + if (!active || ch.isClosed() || ch.getEncodeProtocol() != Protocol.GAME) { return; } From adc6feafd8af02ba37f89bff5894e391a999e137 Mon Sep 17 00:00:00 2001 From: Florian Stober Date: Sun, 5 Nov 2023 19:17:11 +0100 Subject: [PATCH 03/10] clear custom slots on server switch, should have the same effect as reloading the plugin; see #731 --- .../bungeetablistplus/handler/NewTabOverlayHandler.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bungee/src/main/java/codecrafter47/bungeetablistplus/handler/NewTabOverlayHandler.java b/bungee/src/main/java/codecrafter47/bungeetablistplus/handler/NewTabOverlayHandler.java index ffeef845..859b8ea7 100644 --- a/bungee/src/main/java/codecrafter47/bungeetablistplus/handler/NewTabOverlayHandler.java +++ b/bungee/src/main/java/codecrafter47/bungeetablistplus/handler/NewTabOverlayHandler.java @@ -651,7 +651,9 @@ private String getCustomSlotUsername(int index) { @Override void onServerSwitch() { - // do nothing + if (player.getPendingConnection().getVersion() >= 764) { + clearCustomSlots(); + } } @Override @@ -688,6 +690,10 @@ private void createTeamsIfNecessary() { @Override void onDeactivated() { + clearCustomSlots(); + } + + private void clearCustomSlots() { int customSlots = 0; for (int index = 0; index < 80; index++) { if (slotState[index] != SlotState.UNUSED) { From 9b6f6133333b78a2e6e5b005d06d4f1b4189e00b Mon Sep 17 00:00:00 2001 From: Florian Stober Date: Sun, 5 Nov 2023 20:01:04 +0100 Subject: [PATCH 04/10] update for lates BungeeCord; see #735 --- .../AbstractLegacyTabOverlayHandler.java | 31 ++-- .../handler/AbstractTabOverlayHandler.java | 168 +++++------------- .../handler/NewTabOverlayHandler.java | 56 +++--- 3 files changed, 90 insertions(+), 165 deletions(-) diff --git a/bungee/src/main/java/codecrafter47/bungeetablistplus/handler/AbstractLegacyTabOverlayHandler.java b/bungee/src/main/java/codecrafter47/bungeetablistplus/handler/AbstractLegacyTabOverlayHandler.java index ba8fe50c..f64528c2 100644 --- a/bungee/src/main/java/codecrafter47/bungeetablistplus/handler/AbstractLegacyTabOverlayHandler.java +++ b/bungee/src/main/java/codecrafter47/bungeetablistplus/handler/AbstractLegacyTabOverlayHandler.java @@ -37,6 +37,7 @@ import lombok.AllArgsConstructor; import lombok.val; import net.md_5.bungee.api.ChatColor; +import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.packet.*; @@ -248,7 +249,7 @@ private void removeEntry(UUID uuid, String player) { PlayerListItem.Item item = new PlayerListItem.Item(); item.setUuid(uuid); item.setUsername(player); - item.setDisplayName(player); + item.setDisplayName(new TextComponent(player)); item.setPing(9999); pli.setItems(new PlayerListItem.Item[]{item}); pli.setAction(PlayerListItem.Action.REMOVE_PLAYER); @@ -312,7 +313,7 @@ void onActivated() { for (val entry : serverPlayerList.object2IntEntrySet()) { PlayerListItem pli = new PlayerListItem(); PlayerListItem.Item item = new PlayerListItem.Item(); - item.setDisplayName(entry.getKey()); + item.setDisplayName(new TextComponent(entry.getKey())); item.setPing(entry.getIntValue()); pli.setItems(new PlayerListItem.Item[]{item}); pli.setAction(PlayerListItem.Action.ADD_PLAYER); @@ -432,17 +433,12 @@ private void updateSize() { Team t = new Team(); t.setName(slotID[index]); t.setMode((byte) 0); - t.setPrefix(tabOverlay.text0[index]); - t.setDisplayName(""); - t.setSuffix(tabOverlay.text1[index]); + t.setPrefix(new TextComponent(tabOverlay.text0[index])); + t.setDisplayName(new TextComponent()); + t.setSuffix(new TextComponent(tabOverlay.text1[index])); t.setPlayers(new String[]{slotID[index]}); t.setNameTagVisibility("always"); t.setCollisionRule("always"); - if (is13OrLater) { - t.setDisplayName(EMPTY_JSON_TEXT); - t.setPrefix("{\"text\":\"" + tabOverlay.text0[index] + "\"}"); - t.setSuffix("{\"text\":\"" + tabOverlay.text1[index] + "\"}"); - } sendPacket(t); } } else { @@ -464,7 +460,7 @@ private void updateSlot(CustomTabOverlay tabOverlay, int index) { item.setUuid(slotUUID[index]); item.setUsername(slotID[index]); Property119Handler.setProperties(item, EMPTY_PROPERTIES); - item.setDisplayName(slotID[index]); + item.setDisplayName(new TextComponent(slotID[index])); item.setPing(tabOverlay.ping[index]); pli.setItems(new PlayerListItem.Item[]{item}); pli.setAction(PlayerListItem.Action.ADD_PLAYER); @@ -476,16 +472,11 @@ private void updateText(CustomTabOverlay tabOverlay, int index) { Team packet = new Team(); packet.setName(slotID[index]); packet.setMode((byte) 2); - packet.setPrefix(tabOverlay.text0[index]); - packet.setDisplayName(""); - packet.setSuffix(tabOverlay.text1[index]); + packet.setPrefix(new TextComponent(tabOverlay.text0[index])); + packet.setDisplayName(new TextComponent()); + packet.setSuffix(new TextComponent(tabOverlay.text1[index])); packet.setNameTagVisibility("always"); packet.setCollisionRule("always"); - if (is13OrLater) { - packet.setDisplayName(EMPTY_JSON_TEXT); - packet.setPrefix("{\"text\":\"" + tabOverlay.text0[index] + "\"}"); - packet.setSuffix("{\"text\":\"" + tabOverlay.text1[index] + "\"}"); - } sendPacket(packet); } } @@ -828,7 +819,7 @@ public boolean isValid() { */ private static String getName(PlayerListItem.Item item) { if (item.getDisplayName() != null) { - return item.getDisplayName(); + return item.getDisplayName().toLegacyText(); } else if (item.getUsername() != null) { return item.getUsername(); } else { diff --git a/bungee/src/main/java/codecrafter47/bungeetablistplus/handler/AbstractTabOverlayHandler.java b/bungee/src/main/java/codecrafter47/bungeetablistplus/handler/AbstractTabOverlayHandler.java index 1130e800..c9418ee9 100644 --- a/bungee/src/main/java/codecrafter47/bungeetablistplus/handler/AbstractTabOverlayHandler.java +++ b/bungee/src/main/java/codecrafter47/bungeetablistplus/handler/AbstractTabOverlayHandler.java @@ -32,6 +32,9 @@ import de.codecrafter47.taboverlay.handler.*; import it.unimi.dsi.fastutil.objects.*; import lombok.*; +import net.md_5.bungee.api.chat.BaseComponent; +import net.md_5.bungee.api.chat.TextComponent; +import net.md_5.bungee.chat.ComponentSerializer; import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.packet.PlayerListHeaderFooter; import net.md_5.bungee.protocol.packet.PlayerListItem; @@ -56,12 +59,9 @@ public abstract class AbstractTabOverlayHandler implements PacketHandler, TabOve private static final boolean OPTION_ENABLE_CUSTOM_SLOT_UUID_COLLISION_CHECK = true; private static final boolean OPTION_ENABLE_CONSISTENCY_CHECKS = true; - private static final String EMPTY_JSON_TEXT = "{\"text\":\"\"}"; + private static final BaseComponent EMPTY_TEXT_COMPONENT = new TextComponent(); protected static final String[][] EMPTY_PROPERTIES_ARRAY = new String[0][]; - private static final boolean TEAM_COLLISION_RULE_SUPPORTED; - private static final boolean USE_PROTOCOL_PROPERTY_TYPE; - private static final ImmutableMap DIMENSION_TO_USED_SLOTS; private static final BitSet[] SIZE_TO_USED_SLOTS; @@ -78,23 +78,6 @@ public abstract class AbstractTabOverlayHandler implements PacketHandler, TabOve private static final Set blockedTeams = new HashSet<>(); static { - // check whether this BungeeCord version supports team's collision rule property - boolean methodPresent = false; - try { - Team.class.getDeclaredMethod("setCollisionRule", String.class); - methodPresent = true; - } catch (NoSuchMethodException ignored) { - } - TEAM_COLLISION_RULE_SUPPORTED = methodPresent; - - methodPresent = false; - try { - Class.forName("net.md_5.bungee.protocol.Property"); - methodPresent = true; - } catch (ClassNotFoundException ignored) { - } - USE_PROTOCOL_PROPERTY_TYPE = methodPresent; - // build the dimension to used slots map (for the rectangular tab overlay) val builder = ImmutableMap.builder(); for (int columns = 1; columns <= 4; columns++) { @@ -176,9 +159,9 @@ public abstract class AbstractTabOverlayHandler implements PacketHandler, TabOve private final Object2ObjectMap serverPlayerList = new Object2ObjectOpenHashMap<>(); protected final Set serverTabListPlayers = new ObjectOpenHashSet<>(); @Nullable - protected String serverHeader = null; + protected BaseComponent serverHeader = null; @Nullable - protected String serverFooter = null; + protected BaseComponent serverFooter = null; protected final Object2ObjectMap serverTeams = new Object2ObjectOpenHashMap<>(); protected final Object2ObjectMap playerToTeamMap = new Object2ObjectOpenHashMap<>(); @@ -188,7 +171,6 @@ public abstract class AbstractTabOverlayHandler implements PacketHandler, TabOve private AbstractHeaderFooterOperationModeHandler activeHeaderFooterHandler; private boolean hasCreatedCustomTeams = false; - private boolean areCustomSlotUsersPartOfTeams = false; private final AtomicBoolean updateScheduledFlag = new AtomicBoolean(false); private final Runnable updateTask = this::update; @@ -285,6 +267,7 @@ public PacketListenerResult onTeamPacket(Team packet) { for (String player : packet.getPlayers()) { if (player.equals("")) { block = true; + break; } } if (block) { @@ -328,9 +311,7 @@ public PacketListenerResult onTeamPacket(Team packet) { teamEntry.setSuffix(packet.getSuffix()); teamEntry.setFriendlyFire(packet.getFriendlyFire()); teamEntry.setNameTagVisibility(packet.getNameTagVisibility()); - if (TEAM_COLLISION_RULE_SUPPORTED) { - teamEntry.setCollisionRule(packet.getCollisionRule()); - } + teamEntry.setCollisionRule(packet.getCollisionRule()); teamEntry.setColor(packet.getColor()); } if (packet.getPlayers() != null) { @@ -378,8 +359,8 @@ public PacketListenerResult onPlayerListHeaderFooterPacket(PlayerListHeaderFoote enterHeaderAndFooterOperationMode(HeaderAndFooterOperationMode.PASS_TROUGH); } - this.serverHeader = packet.getHeader() != null ? packet.getHeader() : EMPTY_JSON_TEXT; - this.serverFooter = packet.getFooter() != null ? packet.getFooter() : EMPTY_JSON_TEXT; + this.serverHeader = packet.getHeader() != null ? packet.getHeader() : EMPTY_TEXT_COMPONENT; + this.serverFooter = packet.getFooter() != null ? packet.getFooter() : EMPTY_TEXT_COMPONENT; return result; } @@ -397,7 +378,6 @@ public void onServerSwitch(boolean is13OrLater) { if (isUsingAltRespawn()) { hasCreatedCustomTeams = false; - areCustomSlotUsersPartOfTeams = false; } try { @@ -433,10 +413,10 @@ public void onServerSwitch(boolean is13OrLater) { serverPlayerList.clear(); if (serverHeader != null) { - serverHeader = EMPTY_JSON_TEXT; + serverHeader = EMPTY_TEXT_COMPONENT; } if (serverFooter != null) { - serverFooter = EMPTY_JSON_TEXT; + serverFooter = EMPTY_TEXT_COMPONENT; } serverTabListPlayers.clear(); @@ -674,7 +654,7 @@ PacketListenerResult onTeamPacket(Team packet) { @Override void onServerSwitch() { - sendPacket(new PlayerListHeaderFooter(EMPTY_JSON_TEXT, EMPTY_JSON_TEXT)); + sendPacket(new PlayerListHeaderFooter(EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT)); } @Override @@ -757,7 +737,7 @@ PacketListenerResult onPlayerListHeaderFooterPacket(PlayerListHeaderFooter packe @Override void onServerSwitch() { - sendPacket(new PlayerListHeaderFooter(EMPTY_JSON_TEXT, EMPTY_JSON_TEXT)); + sendPacket(new PlayerListHeaderFooter(EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT)); } @Override @@ -778,7 +758,7 @@ void onActivated(AbstractHeaderFooterOperationModeHandler previous) { } // fix header/ footer - sendPacket(new PlayerListHeaderFooter(serverHeader != null ? serverHeader : EMPTY_JSON_TEXT, serverFooter != null ? serverFooter : EMPTY_JSON_TEXT)); + sendPacket(new PlayerListHeaderFooter(serverHeader != null ? serverHeader : EMPTY_TEXT_COMPONENT, serverFooter != null ? serverFooter : EMPTY_TEXT_COMPONENT)); } } @@ -995,11 +975,7 @@ PacketListenerResult onPlayerListPacket(PlayerListItem packet) { // 2. add player to correct team sendPacket(createPacketTeamAddPlayers(playerTeamName, new String[]{slotUsername[index]})); // 3. reset custom slot team - if (is13OrLater) { - sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], EMPTY_JSON_TEXT, EMPTY_JSON_TEXT, EMPTY_JSON_TEXT, "always", "always", 21, (byte) 1)); - } else { - sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], "", "", "", "always", "always", 0, (byte) 1)); - } + sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, "always", "always", 21, (byte) 1)); } } @@ -1075,11 +1051,7 @@ void onTeamPacketPreprocess(Team packet) { int slot = playerUsernameToSlotMap.getInt(playerName); if (slot != -1) { // reset slot team - if (is13OrLater) { - sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[slot], EMPTY_JSON_TEXT, EMPTY_JSON_TEXT, EMPTY_JSON_TEXT, "always", "always", 21, (byte) 1)); - } else { - sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[slot], "", "", "", "always", "always", 0, (byte) 1)); - } + sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[slot], EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, "always", "always", 21, (byte) 1)); } } } @@ -1157,11 +1129,7 @@ PacketListenerResult onTeamPacket(Team packet) { filteredPlayers[j++] = playerName; } else { // reset slot team - if (is13OrLater) { - sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[slot], EMPTY_JSON_TEXT, EMPTY_JSON_TEXT, EMPTY_JSON_TEXT, "always", "always", 21, (byte) 1)); - } else { - sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[slot], "", "", "", "always", "always", 0, (byte) 1)); - } + sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[slot], EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, "always", "always", 21, (byte) 1)); } } packet.setPlayers(filteredPlayers); @@ -1235,11 +1203,7 @@ void onServerSwitch() { // 1. remove player from team sendPacket(createPacketTeamRemovePlayers(CUSTOM_SLOT_TEAMNAME[index], new String[]{slotUsername[index]})); // reset slot team - if (is13OrLater) { - sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], EMPTY_JSON_TEXT, EMPTY_JSON_TEXT, EMPTY_JSON_TEXT, "always", "always", 21, (byte) 1)); - } else { - sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], "", "", "", "always", "always", 0, (byte) 1)); - } + sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, "always", "always", 21, (byte) 1)); } // 2. create new custom slot @@ -1342,26 +1306,12 @@ private void createTeamsIfNecessary() { if (!hasCreatedCustomTeams) { hasCreatedCustomTeams = true; - if (is13OrLater) { - sendPacket(createPacketTeamCreate(CUSTOM_SLOT_TEAMNAME[0], EMPTY_JSON_TEXT, EMPTY_JSON_TEXT, EMPTY_JSON_TEXT, "always", "always", 21, (byte) 1, new String[]{CUSTOM_SLOT_USERNAME[0], CUSTOM_SLOT_USERNAME_SMILEYS[0], ""})); - } else { - sendPacket(createPacketTeamCreate(CUSTOM_SLOT_TEAMNAME[0], "", "", "", "always", "always", 0, (byte) 1, new String[]{CUSTOM_SLOT_USERNAME[0], CUSTOM_SLOT_USERNAME_SMILEYS[0], ""})); - } + sendPacket(createPacketTeamCreate(CUSTOM_SLOT_TEAMNAME[0], EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, "always", "always", 21, (byte) 1, new String[]{CUSTOM_SLOT_USERNAME[0], CUSTOM_SLOT_USERNAME_SMILEYS[0], ""})); for (int i = 1; i < 80; i++) { - if (is13OrLater) { - sendPacket(createPacketTeamCreate(CUSTOM_SLOT_TEAMNAME[i], EMPTY_JSON_TEXT, EMPTY_JSON_TEXT, EMPTY_JSON_TEXT, "always", "always", 21, (byte) 1, new String[]{CUSTOM_SLOT_USERNAME[i], CUSTOM_SLOT_USERNAME_SMILEYS[i]})); - } else { - sendPacket(createPacketTeamCreate(CUSTOM_SLOT_TEAMNAME[i], "", "", "", "always", "always", 0, (byte) 1, new String[]{CUSTOM_SLOT_USERNAME[i], CUSTOM_SLOT_USERNAME_SMILEYS[i]})); - } - } - if (is13OrLater) { - sendPacket(createPacketTeamCreate(CUSTOM_SLOT_TEAMNAME[80], EMPTY_JSON_TEXT, EMPTY_JSON_TEXT, EMPTY_JSON_TEXT, "always", "always", 21, (byte) 1, new String[]{CUSTOM_SLOT_USERNAME[80]})); - } else { - sendPacket(createPacketTeamCreate(CUSTOM_SLOT_TEAMNAME[80], "", "", "", "always", "always", 0, (byte) 1, new String[]{CUSTOM_SLOT_USERNAME[80]})); + sendPacket(createPacketTeamCreate(CUSTOM_SLOT_TEAMNAME[i], EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, "always", "always", 21, (byte) 1, new String[]{CUSTOM_SLOT_USERNAME[i], CUSTOM_SLOT_USERNAME_SMILEYS[i]})); } - - areCustomSlotUsersPartOfTeams = true; + sendPacket(createPacketTeamCreate(CUSTOM_SLOT_TEAMNAME[80], EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, "always", "always", 21, (byte) 1, new String[]{CUSTOM_SLOT_USERNAME[80]})); } } @@ -1380,11 +1330,7 @@ void onDeactivated() { // 2. add player to correct team sendPacket(createPacketTeamAddPlayers(playerTeamName, new String[]{slotUsername[index]})); // 3. reset custom slot team - if (is13OrLater) { - sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], EMPTY_JSON_TEXT, EMPTY_JSON_TEXT, EMPTY_JSON_TEXT, "always", "always", 21, (byte) 1)); - } else { - sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], "", "", "", "always", "always", 0, (byte) 1)); - } + sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, "always", "always", 21, (byte) 1)); } } else { customSlots++; @@ -1516,11 +1462,7 @@ void update() { // 2. add player to correct team sendPacket(createPacketTeamAddPlayers(playerTeamName, new String[]{slotUsername[index]})); // 3. reset custom slot team - if (is13OrLater) { - sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], EMPTY_JSON_TEXT, EMPTY_JSON_TEXT, EMPTY_JSON_TEXT, "always", "always", 21, (byte) 1)); - } else { - sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], "", "", "", "always", "always", 0, (byte) 1)); - } + sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, "always", "always", 21, (byte) 1)); } else { // 2. add player to overflow team sendPacket(createPacketTeamAddPlayers(CUSTOM_SLOT_TEAMNAME[80], new String[]{slotUsername[index]})); @@ -1581,7 +1523,6 @@ void update() { // restore player gamemode PlayerListItem packet; List items = new ArrayList<>(serverPlayerList.size()); - items.clear(); for (PlayerListEntry entry : serverPlayerList.values()) { PlayerListItem.Item item = new PlayerListItem.Item(); item.setUuid(entry.getUuid()); @@ -1709,11 +1650,7 @@ void update() { playerUsernameToSlotMap.removeInt(slotUsername[index]); // reset slot team - if (is13OrLater) { - sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], EMPTY_JSON_TEXT, EMPTY_JSON_TEXT, EMPTY_JSON_TEXT, "always", "always", 21, (byte) 1)); - } else { - sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], "", "", "", "always", "always", 0, (byte) 1)); - } + sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, "always", "always", 21, (byte) 1)); } // 2. update slot state @@ -1734,11 +1671,7 @@ void update() { playerUsernameToSlotMap.removeInt(slotUsername[index]); // reset slot team - if (is13OrLater) { - sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], EMPTY_JSON_TEXT, EMPTY_JSON_TEXT, EMPTY_JSON_TEXT, "always", "always", 21, (byte) 1)); - } else { - sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], "", "", "", "always", "always", 0, (byte) 1)); - } + sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, "always", "always", 21, (byte) 1)); } freePlayers.add(slotUuid[index]); @@ -2064,7 +1997,7 @@ private void sendQueuedItems() { private abstract class CustomContentTabOverlay extends AbstractContentTabOverlay implements TabOverlayHandle.BatchModifiable { final UUID[] uuid; final Icon[] icon; - final String[] text; + final BaseComponent[] text; final int[] ping; final AtomicInteger batchUpdateRecursionLevel; @@ -2078,8 +2011,8 @@ private CustomContentTabOverlay() { this.uuid = new UUID[80]; this.icon = new Icon[80]; Arrays.fill(this.icon, Icon.DEFAULT_STEVE); - this.text = new String[80]; - Arrays.fill(this.text, EMPTY_JSON_TEXT); + this.text = new BaseComponent[80]; + Arrays.fill(this.text, EMPTY_TEXT_COMPONENT); this.ping = new int[80]; this.batchUpdateRecursionLevel = new AtomicInteger(0); this.dirtyFlagSize = true; @@ -2134,8 +2067,9 @@ void setIconInternal(int index, @Nonnull @NonNull Icon icon) { void setTextInternal(int index, @Nonnull @NonNull String text) { String jsonText = ChatFormat.formattedTextToJson(text); - if (!jsonText.equals(this.text[index])) { - this.text[index] = jsonText; + BaseComponent component = ComponentSerializer.deserialize(jsonText); + if (!component.equals(this.text[index])) { + this.text[index] = component; dirtyFlagsText.set(index); scheduleUpdateIfNotInBatch(); } @@ -2219,7 +2153,7 @@ public void setSize(@Nonnull Dimension size) { if (!oldUsedSlots.get(index)) { uuid[index] = null; icon[index] = Icon.DEFAULT_STEVE; - text[index] = EMPTY_JSON_TEXT; + text[index] = EMPTY_TEXT_COMPONENT; ping[index] = 0; } } @@ -2230,7 +2164,7 @@ public void setSize(@Nonnull Dimension size) { if (!newUsedSlots.get(index)) { uuid[index] = null; icon[index] = Icon.DEFAULT_STEVE; - text[index] = EMPTY_JSON_TEXT; + text[index] = EMPTY_TEXT_COMPONENT; ping[index] = 0; } } @@ -2448,7 +2382,7 @@ void onDeactivated() { @Override void onActivated(AbstractHeaderFooterOperationModeHandler previous) { // remove header/ footer - sendPacket(new PlayerListHeaderFooter(EMPTY_JSON_TEXT, EMPTY_JSON_TEXT)); + sendPacket(new PlayerListHeaderFooter(EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT)); } @Override @@ -2462,8 +2396,8 @@ void update() { } private final class CustomHeaderAndFooterImpl extends AbstractHeaderFooterTabOverlay implements HeaderAndFooterHandle { - private String header = EMPTY_JSON_TEXT; - private String footer = EMPTY_JSON_TEXT; + private BaseComponent header = EMPTY_TEXT_COMPONENT; + private BaseComponent footer = EMPTY_TEXT_COMPONENT; private volatile boolean headerOrFooterDirty = false; @@ -2498,22 +2432,22 @@ void scheduleUpdateIfNotInBatch() { @Override public void setHeaderFooter(@Nullable String header, @Nullable String footer) { - this.header = ChatFormat.formattedTextToJson(header); - this.footer = ChatFormat.formattedTextToJson(footer); + this.header = ComponentSerializer.deserialize(ChatFormat.formattedTextToJson(header)); + this.footer = ComponentSerializer.deserialize(ChatFormat.formattedTextToJson(footer)); headerOrFooterDirty = true; scheduleUpdateIfNotInBatch(); } @Override public void setHeader(@Nullable String header) { - this.header = ChatFormat.formattedTextToJson(header); + this.header = ComponentSerializer.deserialize(ChatFormat.formattedTextToJson(header)); headerOrFooterDirty = true; scheduleUpdateIfNotInBatch(); } @Override public void setFooter(@Nullable String footer) { - this.footer = ChatFormat.formattedTextToJson(footer); + this.footer = ComponentSerializer.deserialize(ChatFormat.formattedTextToJson(footer)); headerOrFooterDirty = true; scheduleUpdateIfNotInBatch(); } @@ -2534,7 +2468,7 @@ private static String[][] toPropertiesArray(ProfileProperty textureProperty) { } } - private static Team createPacketTeamCreate(String name, String displayName, String prefix, String suffix, String nameTagVisibility, String collisionRule, int color, byte friendlyFire, String[] players) { + private static Team createPacketTeamCreate(String name, BaseComponent displayName, BaseComponent prefix, BaseComponent suffix, String nameTagVisibility, String collisionRule, int color, byte friendlyFire, String[] players) { Team team = new Team(); team.setName(name); team.setMode((byte) 0); @@ -2542,9 +2476,7 @@ private static Team createPacketTeamCreate(String name, String displayName, Stri team.setPrefix(prefix); team.setSuffix(suffix); team.setNameTagVisibility(nameTagVisibility); - if (TEAM_COLLISION_RULE_SUPPORTED) { - team.setCollisionRule(collisionRule); - } + team.setCollisionRule(collisionRule); team.setColor(color); team.setFriendlyFire(friendlyFire); team.setPlayers(players); @@ -2558,7 +2490,7 @@ private static Team createPacketTeamRemove(String name) { return team; } - private static Team createPacketTeamUpdate(String name, String displayName, String prefix, String suffix, String nameTagVisibility, String collisionRule, int color, byte friendlyFire) { + private static Team createPacketTeamUpdate(String name, BaseComponent displayName, BaseComponent prefix, BaseComponent suffix, String nameTagVisibility, String collisionRule, int color, byte friendlyFire) { Team team = new Team(); team.setName(name); team.setMode((byte) 2); @@ -2566,9 +2498,7 @@ private static Team createPacketTeamUpdate(String name, String displayName, Stri team.setPrefix(prefix); team.setSuffix(suffix); team.setNameTagVisibility(nameTagVisibility); - if (TEAM_COLLISION_RULE_SUPPORTED) { - team.setCollisionRule(collisionRule); - } + team.setCollisionRule(collisionRule); team.setColor(color); team.setFriendlyFire(friendlyFire); return team; @@ -2601,7 +2531,7 @@ static class PlayerListEntry { private UUID uuid; private String[][] properties; private String username; - private String displayName; + private BaseComponent displayName; private int ping; private int gamemode; @@ -2613,9 +2543,9 @@ private PlayerListEntry(PlayerListItem.Item item) { @Data static class TeamEntry { - private String displayName; - private String prefix; - private String suffix; + private BaseComponent displayName; + private BaseComponent prefix; + private BaseComponent suffix; private byte friendlyFire; private String nameTagVisibility; private String collisionRule; diff --git a/bungee/src/main/java/codecrafter47/bungeetablistplus/handler/NewTabOverlayHandler.java b/bungee/src/main/java/codecrafter47/bungeetablistplus/handler/NewTabOverlayHandler.java index 859b8ea7..140d847e 100644 --- a/bungee/src/main/java/codecrafter47/bungeetablistplus/handler/NewTabOverlayHandler.java +++ b/bungee/src/main/java/codecrafter47/bungeetablistplus/handler/NewTabOverlayHandler.java @@ -34,7 +34,10 @@ import it.unimi.dsi.fastutil.objects.*; import lombok.*; import net.md_5.bungee.UserConnection; +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.netty.ChannelWrapper; import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.Protocol; @@ -58,7 +61,7 @@ public class NewTabOverlayHandler implements PacketHandler, TabOverlayHandler { private static final boolean OPTION_ENABLE_CUSTOM_SLOT_USERNAME_COLLISION_CHECK = true; private static final boolean OPTION_ENABLE_CUSTOM_SLOT_UUID_COLLISION_CHECK = true; - private static final String EMPTY_JSON_TEXT = "{\"text\":\"\"}"; + private static final BaseComponent EMPTY_TEXT_COMPONENT = new TextComponent(); protected static final String[][] EMPTY_PROPERTIES_ARRAY = new String[0][]; private static final ImmutableMap DIMENSION_TO_USED_SLOTS; @@ -149,9 +152,9 @@ public class NewTabOverlayHandler implements PacketHandler, TabOverlayHandler { private final Object2BooleanMap serverPlayerListListed = new Object2BooleanOpenHashMap<>(); @Nullable - protected String serverHeader = null; + protected BaseComponent serverHeader = null; @Nullable - protected String serverFooter = null; + protected BaseComponent serverFooter = null; private final Queue> nextActiveContentHandlerQueue = new ConcurrentLinkedQueue<>(); private final Queue> nextActiveHeaderFooterHandlerQueue = new ConcurrentLinkedQueue<>(); @@ -269,8 +272,8 @@ public PacketListenerResult onPlayerListHeaderFooterPacket(PlayerListHeaderFoote enterHeaderAndFooterOperationMode(HeaderAndFooterOperationMode.PASS_TROUGH); } - this.serverHeader = packet.getHeader() != null ? packet.getHeader() : EMPTY_JSON_TEXT; - this.serverFooter = packet.getFooter() != null ? packet.getFooter() : EMPTY_JSON_TEXT; + this.serverHeader = packet.getHeader() != null ? packet.getHeader() : EMPTY_TEXT_COMPONENT; + this.serverFooter = packet.getFooter() != null ? packet.getFooter() : EMPTY_TEXT_COMPONENT; return result; } @@ -299,10 +302,10 @@ public void onServerSwitch(boolean is13OrLater) { serverPlayerListListed.clear(); if (serverHeader != null) { - serverHeader = EMPTY_JSON_TEXT; + serverHeader = EMPTY_TEXT_COMPONENT; } if (serverFooter != null) { - serverFooter = EMPTY_JSON_TEXT; + serverFooter = EMPTY_TEXT_COMPONENT; } active = false; @@ -511,7 +514,7 @@ PacketListenerResult onPlayerListUpdatePacket(PlayerListItemUpdate packet) { @Override void onServerSwitch() { - sendPacket(new PlayerListHeaderFooter(EMPTY_JSON_TEXT, EMPTY_JSON_TEXT)); + sendPacket(new PlayerListHeaderFooter(EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT)); } @Override @@ -566,7 +569,7 @@ PacketListenerResult onPlayerListHeaderFooterPacket(PlayerListHeaderFooter packe @Override void onServerSwitch() { - sendPacket(new PlayerListHeaderFooter(EMPTY_JSON_TEXT, EMPTY_JSON_TEXT)); + sendPacket(new PlayerListHeaderFooter(EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT)); } @Override @@ -587,7 +590,7 @@ void onActivated(AbstractHeaderFooterOperationModeHandler previous) { } // fix header/ footer - sendPacket(new PlayerListHeaderFooter(serverHeader != null ? serverHeader : EMPTY_JSON_TEXT, serverFooter != null ? serverFooter : EMPTY_JSON_TEXT)); + sendPacket(new PlayerListHeaderFooter(serverHeader != null ? serverHeader : EMPTY_TEXT_COMPONENT, serverFooter != null ? serverFooter : EMPTY_TEXT_COMPONENT)); } } @@ -683,7 +686,7 @@ private void createTeamsIfNecessary() { hasCreatedCustomTeams = true; for (int i = 0; i < 80; i++) { - sendPacket(createPacketTeamCreate(CUSTOM_SLOT_TEAMNAME[i], EMPTY_JSON_TEXT, EMPTY_JSON_TEXT, EMPTY_JSON_TEXT, "always", "always", 21, (byte) 1, new String[]{CUSTOM_SLOT_USERNAME[i], CUSTOM_SLOT_USERNAME_SMILEYS[i]})); + sendPacket(createPacketTeamCreate(CUSTOM_SLOT_TEAMNAME[i], EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, "always", "always", 21, (byte) 1, new String[]{CUSTOM_SLOT_USERNAME[i], CUSTOM_SLOT_USERNAME_SMILEYS[i]})); } } } @@ -832,7 +835,7 @@ private boolean isExperimentalTabCompleteSmileys() { private abstract class CustomContentTabOverlay extends AbstractContentTabOverlay implements TabOverlayHandle.BatchModifiable { final Icon[] icon; - final String[] text; + final BaseComponent[] text; final int[] ping; final AtomicInteger batchUpdateRecursionLevel; @@ -844,8 +847,8 @@ private abstract class CustomContentTabOverlay extends AbstractContentTabOverlay private CustomContentTabOverlay() { this.icon = new Icon[80]; Arrays.fill(this.icon, Icon.DEFAULT_STEVE); - this.text = new String[80]; - Arrays.fill(this.text, EMPTY_JSON_TEXT); + this.text = new BaseComponent[80]; + Arrays.fill(this.text, EMPTY_TEXT_COMPONENT); this.ping = new int[80]; this.batchUpdateRecursionLevel = new AtomicInteger(0); this.dirtyFlagSize = true; @@ -891,8 +894,9 @@ void setIconInternal(int index, @Nonnull @NonNull Icon icon) { void setTextInternal(int index, @Nonnull @NonNull String text) { String jsonText = ChatFormat.formattedTextToJson(text); - if (!jsonText.equals(this.text[index])) { - this.text[index] = jsonText; + BaseComponent component = ComponentSerializer.deserialize(jsonText); + if (!component.equals(this.text[index])) { + this.text[index] = component; dirtyFlagsText.set(index); scheduleUpdateIfNotInBatch(); } @@ -959,7 +963,7 @@ public void setSize(@Nonnull Dimension size) { for (int index = newUsedSlots.nextSetBit(0); index >= 0; index = newUsedSlots.nextSetBit(index + 1)) { if (!oldUsedSlots.get(index)) { icon[index] = Icon.DEFAULT_STEVE; - text[index] = EMPTY_JSON_TEXT; + text[index] = EMPTY_TEXT_COMPONENT; ping[index] = 0; } } @@ -969,7 +973,7 @@ public void setSize(@Nonnull Dimension size) { for (int index = oldUsedSlots.nextSetBit(0); index >= 0; index = oldUsedSlots.nextSetBit(index + 1)) { if (!newUsedSlots.get(index)) { icon[index] = Icon.DEFAULT_STEVE; - text[index] = EMPTY_JSON_TEXT; + text[index] = EMPTY_TEXT_COMPONENT; ping[index] = 0; } } @@ -1161,7 +1165,7 @@ void onDeactivated() { @Override void onActivated(AbstractHeaderFooterOperationModeHandler previous) { // remove header/ footer - sendPacket(new PlayerListHeaderFooter(EMPTY_JSON_TEXT, EMPTY_JSON_TEXT)); + sendPacket(new PlayerListHeaderFooter(EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT)); } @Override @@ -1175,8 +1179,8 @@ void update() { } private final class CustomHeaderAndFooterImpl extends AbstractHeaderFooterTabOverlay implements HeaderAndFooterHandle { - private String header = EMPTY_JSON_TEXT; - private String footer = EMPTY_JSON_TEXT; + private BaseComponent header = EMPTY_TEXT_COMPONENT; + private BaseComponent footer = EMPTY_TEXT_COMPONENT; private volatile boolean headerOrFooterDirty = false; @@ -1211,22 +1215,22 @@ void scheduleUpdateIfNotInBatch() { @Override public void setHeaderFooter(@Nullable String header, @Nullable String footer) { - this.header = ChatFormat.formattedTextToJson(header); - this.footer = ChatFormat.formattedTextToJson(footer); + this.header = ComponentSerializer.deserialize(ChatFormat.formattedTextToJson(header)); + this.footer = ComponentSerializer.deserialize(ChatFormat.formattedTextToJson(footer)); headerOrFooterDirty = true; scheduleUpdateIfNotInBatch(); } @Override public void setHeader(@Nullable String header) { - this.header = ChatFormat.formattedTextToJson(header); + this.header = ComponentSerializer.deserialize(ChatFormat.formattedTextToJson(header)); headerOrFooterDirty = true; scheduleUpdateIfNotInBatch(); } @Override public void setFooter(@Nullable String footer) { - this.footer = ChatFormat.formattedTextToJson(footer); + this.footer = ComponentSerializer.deserialize(ChatFormat.formattedTextToJson(footer)); headerOrFooterDirty = true; scheduleUpdateIfNotInBatch(); } @@ -1246,7 +1250,7 @@ private static String[][] toPropertiesArray(ProfileProperty textureProperty) { } } - private static Team createPacketTeamCreate(String name, String displayName, String prefix, String suffix, String nameTagVisibility, String collisionRule, int color, byte friendlyFire, String[] players) { + private static Team createPacketTeamCreate(String name, BaseComponent displayName, BaseComponent prefix, BaseComponent suffix, String nameTagVisibility, String collisionRule, int color, byte friendlyFire, String[] players) { Team team = new Team(); team.setName(name); team.setMode((byte) 0); From 6226598fe7c66c178377abec065c4fabb9a7e886 Mon Sep 17 00:00:00 2001 From: Florian Stober Date: Sun, 5 Nov 2023 20:06:45 +0100 Subject: [PATCH 05/10] fix issue introduced in adc6feaf --- .../bungeetablistplus/handler/NewTabOverlayHandler.java | 1 + 1 file changed, 1 insertion(+) diff --git a/bungee/src/main/java/codecrafter47/bungeetablistplus/handler/NewTabOverlayHandler.java b/bungee/src/main/java/codecrafter47/bungeetablistplus/handler/NewTabOverlayHandler.java index 140d847e..b7bf2c21 100644 --- a/bungee/src/main/java/codecrafter47/bungeetablistplus/handler/NewTabOverlayHandler.java +++ b/bungee/src/main/java/codecrafter47/bungeetablistplus/handler/NewTabOverlayHandler.java @@ -701,6 +701,7 @@ private void clearCustomSlots() { for (int index = 0; index < 80; index++) { if (slotState[index] != SlotState.UNUSED) { customSlots++; + dirtySlots.set(index); } } From 8a864d8bbb52809bed9ba8771127f513fed44728 Mon Sep 17 00:00:00 2001 From: Florian Stober Date: Sun, 5 Nov 2023 20:07:08 +0100 Subject: [PATCH 06/10] update TabOverlayCommon --- TabOverlayCommon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TabOverlayCommon b/TabOverlayCommon index 75e4529f..3545bf42 160000 --- a/TabOverlayCommon +++ b/TabOverlayCommon @@ -1 +1 @@ -Subproject commit 75e4529f58d0bf1d8ace537af7d5a49bbc2e8308 +Subproject commit 3545bf42740e733718c7a27b442ef8bf121a4e44 From aa5ccb906384b26243edfced56ab9315cbd9fe52 Mon Sep 17 00:00:00 2001 From: Florian Stober Date: Sun, 5 Nov 2023 20:15:46 +0100 Subject: [PATCH 07/10] check minimum required BungeeCord version --- .../bungeetablistplus/BungeeTabListPlus.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/bungee/src/main/java/codecrafter47/bungeetablistplus/BungeeTabListPlus.java b/bungee/src/main/java/codecrafter47/bungeetablistplus/BungeeTabListPlus.java index 0a245fa5..7b8d6a52 100644 --- a/bungee/src/main/java/codecrafter47/bungeetablistplus/BungeeTabListPlus.java +++ b/bungee/src/main/java/codecrafter47/bungeetablistplus/BungeeTabListPlus.java @@ -66,8 +66,10 @@ import lombok.val; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ProxyServer; +import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.connection.Connection; import net.md_5.bungee.api.plugin.Plugin; +import net.md_5.bungee.protocol.packet.PlayerListHeaderFooter; import org.bstats.bungeecord.Metrics; import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.error.YAMLException; @@ -185,19 +187,25 @@ public void onLoad() { try { Class.forName("net.md_5.bungee.api.Title"); } catch (ClassNotFoundException ex) { - throw new RuntimeException("You need to run at least BungeeCord version #1671"); + throw new RuntimeException("You need to run at least BungeeCord version #1760"); } try { Connection.class.getMethod("isConnected"); } catch (NoSuchMethodException ex) { - throw new RuntimeException("You need to run at least BungeeCord version #1671"); + throw new RuntimeException("You need to run at least BungeeCord version #1760"); } try { Class.forName("net.md_5.bungee.protocol.packet.PlayerListItemUpdate"); } catch (ClassNotFoundException ex) { - throw new RuntimeException("You need to run at least BungeeCord version #1671"); + throw new RuntimeException("You need to run at least BungeeCord version #1760"); + } + + try { + PlayerListHeaderFooter.class.getMethod("setHeader", BaseComponent.class); + } catch (NoSuchMethodException ex) { + throw new RuntimeException("You need to run at least BungeeCord version #1760"); } INSTANCE = this; From 9c56d1b048ebff69837bf402025838690b8d5674 Mon Sep 17 00:00:00 2001 From: Florian Stober Date: Wed, 8 Nov 2023 10:22:54 +0100 Subject: [PATCH 08/10] update for latest BungeeCord; see #735 --- .../bungeetablistplus/BungeeTabListPlus.java | 14 +++++-- .../AbstractLegacyTabOverlayHandler.java | 13 +++--- .../handler/AbstractTabOverlayHandler.java | 40 +++++++++++-------- .../handler/NewTabOverlayHandler.java | 6 ++- 4 files changed, 45 insertions(+), 28 deletions(-) diff --git a/bungee/src/main/java/codecrafter47/bungeetablistplus/BungeeTabListPlus.java b/bungee/src/main/java/codecrafter47/bungeetablistplus/BungeeTabListPlus.java index 7b8d6a52..e21efd0d 100644 --- a/bungee/src/main/java/codecrafter47/bungeetablistplus/BungeeTabListPlus.java +++ b/bungee/src/main/java/codecrafter47/bungeetablistplus/BungeeTabListPlus.java @@ -187,25 +187,31 @@ public void onLoad() { try { Class.forName("net.md_5.bungee.api.Title"); } catch (ClassNotFoundException ex) { - throw new RuntimeException("You need to run at least BungeeCord version #1760"); + throw new RuntimeException("You need to run at least BungeeCord version #1766"); } try { Connection.class.getMethod("isConnected"); } catch (NoSuchMethodException ex) { - throw new RuntimeException("You need to run at least BungeeCord version #1760"); + throw new RuntimeException("You need to run at least BungeeCord version #1766"); } try { Class.forName("net.md_5.bungee.protocol.packet.PlayerListItemUpdate"); } catch (ClassNotFoundException ex) { - throw new RuntimeException("You need to run at least BungeeCord version #1760"); + throw new RuntimeException("You need to run at least BungeeCord version #1766"); } try { PlayerListHeaderFooter.class.getMethod("setHeader", BaseComponent.class); } catch (NoSuchMethodException ex) { - throw new RuntimeException("You need to run at least BungeeCord version #1760"); + throw new RuntimeException("You need to run at least BungeeCord version #1766"); + } + + try { + Class.forName("net.md_5.bungee.protocol.Either"); + } catch (ClassNotFoundException ex) { + throw new RuntimeException("You need to run at least BungeeCord version #1766"); } INSTANCE = this; diff --git a/bungee/src/main/java/codecrafter47/bungeetablistplus/handler/AbstractLegacyTabOverlayHandler.java b/bungee/src/main/java/codecrafter47/bungeetablistplus/handler/AbstractLegacyTabOverlayHandler.java index f64528c2..1d6a018a 100644 --- a/bungee/src/main/java/codecrafter47/bungeetablistplus/handler/AbstractLegacyTabOverlayHandler.java +++ b/bungee/src/main/java/codecrafter47/bungeetablistplus/handler/AbstractLegacyTabOverlayHandler.java @@ -39,6 +39,7 @@ import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.protocol.DefinedPacket; +import net.md_5.bungee.protocol.Either; import net.md_5.bungee.protocol.packet.*; import javax.annotation.Nonnull; @@ -433,9 +434,9 @@ private void updateSize() { Team t = new Team(); t.setName(slotID[index]); t.setMode((byte) 0); - t.setPrefix(new TextComponent(tabOverlay.text0[index])); - t.setDisplayName(new TextComponent()); - t.setSuffix(new TextComponent(tabOverlay.text1[index])); + t.setPrefix(Either.left(tabOverlay.text0[index])); + t.setDisplayName(Either.left("")); + t.setSuffix(Either.left(tabOverlay.text1[index])); t.setPlayers(new String[]{slotID[index]}); t.setNameTagVisibility("always"); t.setCollisionRule("always"); @@ -472,9 +473,9 @@ private void updateText(CustomTabOverlay tabOverlay, int index) { Team packet = new Team(); packet.setName(slotID[index]); packet.setMode((byte) 2); - packet.setPrefix(new TextComponent(tabOverlay.text0[index])); - packet.setDisplayName(new TextComponent()); - packet.setSuffix(new TextComponent(tabOverlay.text1[index])); + packet.setPrefix(Either.left(tabOverlay.text0[index])); + packet.setDisplayName(Either.left("")); + packet.setSuffix(Either.left(tabOverlay.text1[index])); packet.setNameTagVisibility("always"); packet.setCollisionRule("always"); sendPacket(packet); diff --git a/bungee/src/main/java/codecrafter47/bungeetablistplus/handler/AbstractTabOverlayHandler.java b/bungee/src/main/java/codecrafter47/bungeetablistplus/handler/AbstractTabOverlayHandler.java index c9418ee9..61e51d03 100644 --- a/bungee/src/main/java/codecrafter47/bungeetablistplus/handler/AbstractTabOverlayHandler.java +++ b/bungee/src/main/java/codecrafter47/bungeetablistplus/handler/AbstractTabOverlayHandler.java @@ -36,6 +36,7 @@ import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.chat.ComponentSerializer; import net.md_5.bungee.protocol.DefinedPacket; +import net.md_5.bungee.protocol.Either; import net.md_5.bungee.protocol.packet.PlayerListHeaderFooter; import net.md_5.bungee.protocol.packet.PlayerListItem; import net.md_5.bungee.protocol.packet.Team; @@ -180,6 +181,8 @@ public abstract class AbstractTabOverlayHandler implements PacketHandler, TabOve private boolean is119OrLater; protected boolean active; + private final Either emptyEither; + public AbstractTabOverlayHandler(Logger logger, Executor eventLoopExecutor, UUID viewerUuid, boolean is18, boolean is13OrLater, boolean is119OrLater) { this.logger = logger; this.eventLoopExecutor = eventLoopExecutor; @@ -189,6 +192,11 @@ public AbstractTabOverlayHandler(Logger logger, Executor eventLoopExecutor, UUID this.is119OrLater = is119OrLater; this.activeContentHandler = new PassThroughContentHandler(); this.activeHeaderFooterHandler = new PassThroughHeaderFooterHandler(); + if (is13OrLater) { + emptyEither = Either.right(EMPTY_TEXT_COMPONENT); + } else { + emptyEither = Either.left(""); + } } protected abstract void sendPacket(DefinedPacket packet); @@ -975,7 +983,7 @@ PacketListenerResult onPlayerListPacket(PlayerListItem packet) { // 2. add player to correct team sendPacket(createPacketTeamAddPlayers(playerTeamName, new String[]{slotUsername[index]})); // 3. reset custom slot team - sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, "always", "always", 21, (byte) 1)); + sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], emptyEither, emptyEither, emptyEither, "always", "always", 21, (byte) 1)); } } @@ -1051,7 +1059,7 @@ void onTeamPacketPreprocess(Team packet) { int slot = playerUsernameToSlotMap.getInt(playerName); if (slot != -1) { // reset slot team - sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[slot], EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, "always", "always", 21, (byte) 1)); + sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[slot], emptyEither, emptyEither, emptyEither, "always", "always", 21, (byte) 1)); } } } @@ -1129,7 +1137,7 @@ PacketListenerResult onTeamPacket(Team packet) { filteredPlayers[j++] = playerName; } else { // reset slot team - sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[slot], EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, "always", "always", 21, (byte) 1)); + sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[slot], emptyEither, emptyEither, emptyEither, "always", "always", 21, (byte) 1)); } } packet.setPlayers(filteredPlayers); @@ -1203,7 +1211,7 @@ void onServerSwitch() { // 1. remove player from team sendPacket(createPacketTeamRemovePlayers(CUSTOM_SLOT_TEAMNAME[index], new String[]{slotUsername[index]})); // reset slot team - sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, "always", "always", 21, (byte) 1)); + sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], emptyEither, emptyEither, emptyEither, "always", "always", 21, (byte) 1)); } // 2. create new custom slot @@ -1306,12 +1314,12 @@ private void createTeamsIfNecessary() { if (!hasCreatedCustomTeams) { hasCreatedCustomTeams = true; - sendPacket(createPacketTeamCreate(CUSTOM_SLOT_TEAMNAME[0], EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, "always", "always", 21, (byte) 1, new String[]{CUSTOM_SLOT_USERNAME[0], CUSTOM_SLOT_USERNAME_SMILEYS[0], ""})); + sendPacket(createPacketTeamCreate(CUSTOM_SLOT_TEAMNAME[0], emptyEither, emptyEither, emptyEither, "always", "always", 21, (byte) 1, new String[]{CUSTOM_SLOT_USERNAME[0], CUSTOM_SLOT_USERNAME_SMILEYS[0], ""})); for (int i = 1; i < 80; i++) { - sendPacket(createPacketTeamCreate(CUSTOM_SLOT_TEAMNAME[i], EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, "always", "always", 21, (byte) 1, new String[]{CUSTOM_SLOT_USERNAME[i], CUSTOM_SLOT_USERNAME_SMILEYS[i]})); + sendPacket(createPacketTeamCreate(CUSTOM_SLOT_TEAMNAME[i], emptyEither, emptyEither, emptyEither, "always", "always", 21, (byte) 1, new String[]{CUSTOM_SLOT_USERNAME[i], CUSTOM_SLOT_USERNAME_SMILEYS[i]})); } - sendPacket(createPacketTeamCreate(CUSTOM_SLOT_TEAMNAME[80], EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, "always", "always", 21, (byte) 1, new String[]{CUSTOM_SLOT_USERNAME[80]})); + sendPacket(createPacketTeamCreate(CUSTOM_SLOT_TEAMNAME[80], emptyEither, emptyEither, emptyEither, "always", "always", 21, (byte) 1, new String[]{CUSTOM_SLOT_USERNAME[80]})); } } @@ -1330,7 +1338,7 @@ void onDeactivated() { // 2. add player to correct team sendPacket(createPacketTeamAddPlayers(playerTeamName, new String[]{slotUsername[index]})); // 3. reset custom slot team - sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, "always", "always", 21, (byte) 1)); + sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], emptyEither, emptyEither, emptyEither, "always", "always", 21, (byte) 1)); } } else { customSlots++; @@ -1462,7 +1470,7 @@ void update() { // 2. add player to correct team sendPacket(createPacketTeamAddPlayers(playerTeamName, new String[]{slotUsername[index]})); // 3. reset custom slot team - sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, "always", "always", 21, (byte) 1)); + sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], emptyEither, emptyEither, emptyEither, "always", "always", 21, (byte) 1)); } else { // 2. add player to overflow team sendPacket(createPacketTeamAddPlayers(CUSTOM_SLOT_TEAMNAME[80], new String[]{slotUsername[index]})); @@ -1650,7 +1658,7 @@ void update() { playerUsernameToSlotMap.removeInt(slotUsername[index]); // reset slot team - sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, "always", "always", 21, (byte) 1)); + sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], emptyEither, emptyEither, emptyEither, "always", "always", 21, (byte) 1)); } // 2. update slot state @@ -1671,7 +1679,7 @@ void update() { playerUsernameToSlotMap.removeInt(slotUsername[index]); // reset slot team - sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, "always", "always", 21, (byte) 1)); + sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], emptyEither, emptyEither, emptyEither, "always", "always", 21, (byte) 1)); } freePlayers.add(slotUuid[index]); @@ -2468,7 +2476,7 @@ private static String[][] toPropertiesArray(ProfileProperty textureProperty) { } } - private static Team createPacketTeamCreate(String name, BaseComponent displayName, BaseComponent prefix, BaseComponent suffix, String nameTagVisibility, String collisionRule, int color, byte friendlyFire, String[] players) { + private static Team createPacketTeamCreate(String name, Either displayName, Either prefix, Either suffix, String nameTagVisibility, String collisionRule, int color, byte friendlyFire, String[] players) { Team team = new Team(); team.setName(name); team.setMode((byte) 0); @@ -2490,7 +2498,7 @@ private static Team createPacketTeamRemove(String name) { return team; } - private static Team createPacketTeamUpdate(String name, BaseComponent displayName, BaseComponent prefix, BaseComponent suffix, String nameTagVisibility, String collisionRule, int color, byte friendlyFire) { + private static Team createPacketTeamUpdate(String name, Either displayName, Either prefix, Either suffix, String nameTagVisibility, String collisionRule, int color, byte friendlyFire) { Team team = new Team(); team.setName(name); team.setMode((byte) 2); @@ -2543,9 +2551,9 @@ private PlayerListEntry(PlayerListItem.Item item) { @Data static class TeamEntry { - private BaseComponent displayName; - private BaseComponent prefix; - private BaseComponent suffix; + private Either displayName; + private Either prefix; + private Either suffix; private byte friendlyFire; private String nameTagVisibility; private String collisionRule; diff --git a/bungee/src/main/java/codecrafter47/bungeetablistplus/handler/NewTabOverlayHandler.java b/bungee/src/main/java/codecrafter47/bungeetablistplus/handler/NewTabOverlayHandler.java index b7bf2c21..82c296ad 100644 --- a/bungee/src/main/java/codecrafter47/bungeetablistplus/handler/NewTabOverlayHandler.java +++ b/bungee/src/main/java/codecrafter47/bungeetablistplus/handler/NewTabOverlayHandler.java @@ -40,6 +40,7 @@ import net.md_5.bungee.chat.ComponentSerializer; import net.md_5.bungee.netty.ChannelWrapper; import net.md_5.bungee.protocol.DefinedPacket; +import net.md_5.bungee.protocol.Either; import net.md_5.bungee.protocol.Protocol; import net.md_5.bungee.protocol.packet.*; @@ -62,6 +63,7 @@ public class NewTabOverlayHandler implements PacketHandler, TabOverlayHandler { private static final boolean OPTION_ENABLE_CUSTOM_SLOT_UUID_COLLISION_CHECK = true; private static final BaseComponent EMPTY_TEXT_COMPONENT = new TextComponent(); + private static final Either EMPTY_EITHER_TEXT_COMPONENT = Either.right(new TextComponent()); protected static final String[][] EMPTY_PROPERTIES_ARRAY = new String[0][]; private static final ImmutableMap DIMENSION_TO_USED_SLOTS; @@ -686,7 +688,7 @@ private void createTeamsIfNecessary() { hasCreatedCustomTeams = true; for (int i = 0; i < 80; i++) { - sendPacket(createPacketTeamCreate(CUSTOM_SLOT_TEAMNAME[i], EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, EMPTY_TEXT_COMPONENT, "always", "always", 21, (byte) 1, new String[]{CUSTOM_SLOT_USERNAME[i], CUSTOM_SLOT_USERNAME_SMILEYS[i]})); + sendPacket(createPacketTeamCreate(CUSTOM_SLOT_TEAMNAME[i], EMPTY_EITHER_TEXT_COMPONENT, EMPTY_EITHER_TEXT_COMPONENT, EMPTY_EITHER_TEXT_COMPONENT, "always", "always", 21, (byte) 1, new String[]{CUSTOM_SLOT_USERNAME[i], CUSTOM_SLOT_USERNAME_SMILEYS[i]})); } } } @@ -1251,7 +1253,7 @@ private static String[][] toPropertiesArray(ProfileProperty textureProperty) { } } - private static Team createPacketTeamCreate(String name, BaseComponent displayName, BaseComponent prefix, BaseComponent suffix, String nameTagVisibility, String collisionRule, int color, byte friendlyFire, String[] players) { + private static Team createPacketTeamCreate(String name, Either displayName, Either prefix, Either suffix, String nameTagVisibility, String collisionRule, int color, byte friendlyFire, String[] players) { Team team = new Team(); team.setName(name); team.setMode((byte) 0); From 6b522635af3361fd47b29ce85704e87fd5c4c62f Mon Sep 17 00:00:00 2001 From: Nick <29809309+PrinceBunBun981@users.noreply.github.com> Date: Thu, 9 Nov 2023 13:55:54 -0500 Subject: [PATCH 09/10] Fix an issue related to 1.8.8 connections. --- .../handler/AbstractTabOverlayHandler.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/bungee/src/main/java/codecrafter47/bungeetablistplus/handler/AbstractTabOverlayHandler.java b/bungee/src/main/java/codecrafter47/bungeetablistplus/handler/AbstractTabOverlayHandler.java index 61e51d03..61d20d19 100644 --- a/bungee/src/main/java/codecrafter47/bungeetablistplus/handler/AbstractTabOverlayHandler.java +++ b/bungee/src/main/java/codecrafter47/bungeetablistplus/handler/AbstractTabOverlayHandler.java @@ -983,7 +983,7 @@ PacketListenerResult onPlayerListPacket(PlayerListItem packet) { // 2. add player to correct team sendPacket(createPacketTeamAddPlayers(playerTeamName, new String[]{slotUsername[index]})); // 3. reset custom slot team - sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], emptyEither, emptyEither, emptyEither, "always", "always", 21, (byte) 1)); + sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], emptyEither, emptyEither, emptyEither, "always", "always", is13OrLater ? 21 : 0, (byte) 1)); } } @@ -1059,7 +1059,7 @@ void onTeamPacketPreprocess(Team packet) { int slot = playerUsernameToSlotMap.getInt(playerName); if (slot != -1) { // reset slot team - sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[slot], emptyEither, emptyEither, emptyEither, "always", "always", 21, (byte) 1)); + sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[slot], emptyEither, emptyEither, emptyEither, "always", "always", is13OrLater ? 21 : 0, (byte) 1)); } } } @@ -1137,7 +1137,7 @@ PacketListenerResult onTeamPacket(Team packet) { filteredPlayers[j++] = playerName; } else { // reset slot team - sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[slot], emptyEither, emptyEither, emptyEither, "always", "always", 21, (byte) 1)); + sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[slot], emptyEither, emptyEither, emptyEither, "always", "always", is13OrLater ? 21 : 0, (byte) 1)); } } packet.setPlayers(filteredPlayers); @@ -1211,7 +1211,7 @@ void onServerSwitch() { // 1. remove player from team sendPacket(createPacketTeamRemovePlayers(CUSTOM_SLOT_TEAMNAME[index], new String[]{slotUsername[index]})); // reset slot team - sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], emptyEither, emptyEither, emptyEither, "always", "always", 21, (byte) 1)); + sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], emptyEither, emptyEither, emptyEither, "always", "always", is13OrLater ? 21 : 0, (byte) 1)); } // 2. create new custom slot @@ -1314,12 +1314,12 @@ private void createTeamsIfNecessary() { if (!hasCreatedCustomTeams) { hasCreatedCustomTeams = true; - sendPacket(createPacketTeamCreate(CUSTOM_SLOT_TEAMNAME[0], emptyEither, emptyEither, emptyEither, "always", "always", 21, (byte) 1, new String[]{CUSTOM_SLOT_USERNAME[0], CUSTOM_SLOT_USERNAME_SMILEYS[0], ""})); + sendPacket(createPacketTeamCreate(CUSTOM_SLOT_TEAMNAME[0], emptyEither, emptyEither, emptyEither, "always", "always", is13OrLater ? 21 : 0, (byte) 1, new String[]{CUSTOM_SLOT_USERNAME[0], CUSTOM_SLOT_USERNAME_SMILEYS[0], ""})); for (int i = 1; i < 80; i++) { - sendPacket(createPacketTeamCreate(CUSTOM_SLOT_TEAMNAME[i], emptyEither, emptyEither, emptyEither, "always", "always", 21, (byte) 1, new String[]{CUSTOM_SLOT_USERNAME[i], CUSTOM_SLOT_USERNAME_SMILEYS[i]})); + sendPacket(createPacketTeamCreate(CUSTOM_SLOT_TEAMNAME[i], emptyEither, emptyEither, emptyEither, "always", "always", is13OrLater ? 21 : 0, (byte) 1, new String[]{CUSTOM_SLOT_USERNAME[i], CUSTOM_SLOT_USERNAME_SMILEYS[i]})); } - sendPacket(createPacketTeamCreate(CUSTOM_SLOT_TEAMNAME[80], emptyEither, emptyEither, emptyEither, "always", "always", 21, (byte) 1, new String[]{CUSTOM_SLOT_USERNAME[80]})); + sendPacket(createPacketTeamCreate(CUSTOM_SLOT_TEAMNAME[80], emptyEither, emptyEither, emptyEither, "always", "always", is13OrLater ? 21 : 0, (byte) 1, new String[]{CUSTOM_SLOT_USERNAME[80]})); } } @@ -1338,7 +1338,7 @@ void onDeactivated() { // 2. add player to correct team sendPacket(createPacketTeamAddPlayers(playerTeamName, new String[]{slotUsername[index]})); // 3. reset custom slot team - sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], emptyEither, emptyEither, emptyEither, "always", "always", 21, (byte) 1)); + sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], emptyEither, emptyEither, emptyEither, "always", "always", is13OrLater ? 21 : 0, (byte) 1)); } } else { customSlots++; @@ -1470,7 +1470,7 @@ void update() { // 2. add player to correct team sendPacket(createPacketTeamAddPlayers(playerTeamName, new String[]{slotUsername[index]})); // 3. reset custom slot team - sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], emptyEither, emptyEither, emptyEither, "always", "always", 21, (byte) 1)); + sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], emptyEither, emptyEither, emptyEither, "always", "always", is13OrLater ? 21 : 0, (byte) 1)); } else { // 2. add player to overflow team sendPacket(createPacketTeamAddPlayers(CUSTOM_SLOT_TEAMNAME[80], new String[]{slotUsername[index]})); @@ -1658,7 +1658,7 @@ void update() { playerUsernameToSlotMap.removeInt(slotUsername[index]); // reset slot team - sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], emptyEither, emptyEither, emptyEither, "always", "always", 21, (byte) 1)); + sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], emptyEither, emptyEither, emptyEither, "always", "always", is13OrLater ? 21 : 0, (byte) 1)); } // 2. update slot state @@ -1679,7 +1679,7 @@ void update() { playerUsernameToSlotMap.removeInt(slotUsername[index]); // reset slot team - sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], emptyEither, emptyEither, emptyEither, "always", "always", 21, (byte) 1)); + sendPacket(createPacketTeamUpdate(CUSTOM_SLOT_TEAMNAME[index], emptyEither, emptyEither, emptyEither, "always", "always", is13OrLater ? 21 : 0, (byte) 1)); } freePlayers.add(slotUuid[index]); From 1d49f7b218ed865a8c055682776c96f74668617f Mon Sep 17 00:00:00 2001 From: Florian Stober Date: Sat, 20 Jan 2024 19:01:30 +0100 Subject: [PATCH 10/10] update submodule reference --- TabOverlayCommon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TabOverlayCommon b/TabOverlayCommon index 3545bf42..af983094 160000 --- a/TabOverlayCommon +++ b/TabOverlayCommon @@ -1 +1 @@ -Subproject commit 3545bf42740e733718c7a27b442ef8bf121a4e44 +Subproject commit af983094c422ba7410cc3d322b7e8eb496691638