From 9324a52ce0d0a474e93ee5c269a3e5b519423672 Mon Sep 17 00:00:00 2001 From: Timon Seidel Date: Mon, 31 Mar 2025 19:58:43 +0200 Subject: [PATCH] fix: server link's custom labels not being translated (#1537) --- .../proxy/connection/client/ConnectedPlayer.java | 10 ++++++++-- .../packet/config/ClientboundServerLinksPacket.java | 6 ------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java index ccd09218..7324544d 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java @@ -1101,8 +1101,14 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player, throw new IllegalStateException("Can only send server links in CONFIGURATION or PLAY protocol"); } - connection.write(new ClientboundServerLinksPacket(List.copyOf(links).stream() - .map(l -> new ClientboundServerLinksPacket.ServerLink(l, getProtocolVersion())).toList())); + connection.write(new ClientboundServerLinksPacket(links.stream() + .map(l -> new ClientboundServerLinksPacket.ServerLink( + l.getBuiltInType().map(Enum::ordinal).orElse(-1), + l.getCustomLabel() + .map(c -> new ComponentHolder(getProtocolVersion(), translateMessage(c))) + .orElse(null), + l.getUrl().toString())) + .toList())); } @Override diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/ClientboundServerLinksPacket.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/ClientboundServerLinksPacket.java index 274bbb8f..d37866d8 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/ClientboundServerLinksPacket.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/config/ClientboundServerLinksPacket.java @@ -68,12 +68,6 @@ public class ClientboundServerLinksPacket implements MinecraftPacket { public record ServerLink(int id, ComponentHolder displayName, String url) { - public ServerLink(com.velocitypowered.api.util.ServerLink link, ProtocolVersion protocolVersion) { - this(link.getBuiltInType().map(Enum::ordinal).orElse(-1), - link.getCustomLabel().map(c -> new ComponentHolder(protocolVersion, c)).orElse(null), - link.getUrl().toString()); - } - private static ServerLink read(ByteBuf buf, ProtocolVersion version) { if (buf.readBoolean()) { return new ServerLink(ProtocolUtils.readVarInt(buf), null, ProtocolUtils.readString(buf));