SteamWar/BungeeCore
Archiviert
13
2

Fix Tablist
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2023-12-06 12:33:07 +01:00
Ursprung f270d4197b
Commit 6dd35a265b
2 geänderte Dateien mit 11 neuen und 15 gelöschten Zeilen

Datei anzeigen

@ -89,8 +89,8 @@ 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(wrapName(item.getDisplayName()))) { } else if(!tabItem.getDisplayName().equals(item.getDisplayName())) {
tabItem.setDisplayName(wrapName(item.getDisplayName())); tabItem.setDisplayName(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(wrapName(item.getDisplayName())); tabItem.setDisplayName(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(wrapName(item.getDisplayName())); tabItem.setDisplayName(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(wrapName("")); item.setDisplayName(new TextComponent());
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(wrapName("")); item.setDisplayName(new TextComponent());
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)
@ -304,10 +304,6 @@ public class Tablist extends MessageToMessageDecoder<PacketWrapper> {
return player.getPendingConnection().getVersion() < ProtocolConstants.MINECRAFT_1_19_3; return player.getPendingConnection().getVersion() < ProtocolConstants.MINECRAFT_1_19_3;
} }
private BaseComponent wrapName(String name) {
return new TextComponent(name);
}
private void sendTabPacket(List<PlayerListItem.Item> items, PlayerListItem.Action action) { //Breaks in 1.19.3 if action != UPDATE_DISPLAY_NAME, ADD_PLAYER or REMOVE_PLAYER private void sendTabPacket(List<PlayerListItem.Item> items, PlayerListItem.Action action) { //Breaks in 1.19.3 if action != UPDATE_DISPLAY_NAME, ADD_PLAYER or REMOVE_PLAYER
if(!items.isEmpty()) { if(!items.isEmpty()) {
if(oldTab()) { if(oldTab()) {

Datei anzeigen

@ -22,9 +22,9 @@ package de.steamwar.bungeecore.tablist;
import de.steamwar.messages.ChatSender; import de.steamwar.messages.ChatSender;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserPerm; 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.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.connection.InitialHandler; import net.md_5.bungee.connection.InitialHandler;
import net.md_5.bungee.connection.LoginResult; import net.md_5.bungee.connection.LoginResult;
import net.md_5.bungee.protocol.Property; import net.md_5.bungee.protocol.Property;
@ -47,7 +47,7 @@ interface TablistPart {
} }
private final UUID uuid; private final UUID uuid;
private final String displayName; private final BaseComponent displayName;
private final Property[] properties; private final Property[] properties;
public Item(UUID uuid, String displayName, Property[] properties) { public Item(UUID uuid, String displayName, Property[] properties) {
@ -75,7 +75,7 @@ interface TablistPart {
return uuid; return uuid;
} }
public String getDisplayName() { public BaseComponent getDisplayName() {
return displayName; return displayName;
} }
@ -83,8 +83,8 @@ interface TablistPart {
return properties; return properties;
} }
private String reformat(String string) { private BaseComponent reformat(String string) {
return ComponentSerializer.toString(TextComponent.fromLegacyText(string)); return TextComponent.fromArray(TextComponent.fromLegacyText(string));
} }
} }
} }