From b8fe3577c9582972a92134642e35eb7fac671376 Mon Sep 17 00:00:00 2001 From: Gero Date: Fri, 28 Feb 2025 15:01:20 +0100 Subject: [PATCH] Use correct component serializer in ComponentHolder#getBinaryTag --- .../proxy/protocol/packet/chat/ComponentHolder.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/ComponentHolder.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/ComponentHolder.java index 0935f8ea..22b49621 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/ComponentHolder.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/ComponentHolder.java @@ -43,7 +43,6 @@ import net.kyori.adventure.nbt.LongBinaryTag; import net.kyori.adventure.nbt.ShortBinaryTag; import net.kyori.adventure.nbt.StringBinaryTag; import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.checkerframework.checker.nullness.qual.MonotonicNonNull; @@ -106,16 +105,14 @@ public class ComponentHolder { public BinaryTag getBinaryTag() { if (binaryTag == null) { // TODO: replace this with adventure-text-serializer-nbt - binaryTag = serialize(GsonComponentSerializer.gson().serializeToTree(getComponent())); + binaryTag = serialize(ProtocolUtils.getJsonChatSerializer(version).serializeToTree(getComponent())); } return binaryTag; } public static BinaryTag serialize(JsonElement json) { - if (json instanceof JsonPrimitive) { - JsonPrimitive jsonPrimitive = (JsonPrimitive) json; - - if (jsonPrimitive.isNumber()) { + if (json instanceof JsonPrimitive jsonPrimitive) { + if (jsonPrimitive.isNumber()) { Number number = json.getAsNumber(); if (number instanceof Byte) {