Skip to content

Commit b8fe357

Browse files
committed
Use correct component serializer in ComponentHolder#getBinaryTag
1 parent d4ea40a commit b8fe357

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/ComponentHolder.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
import net.kyori.adventure.nbt.ShortBinaryTag;
4444
import net.kyori.adventure.nbt.StringBinaryTag;
4545
import net.kyori.adventure.text.Component;
46-
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
4746
import org.apache.logging.log4j.LogManager;
4847
import org.apache.logging.log4j.Logger;
4948
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
@@ -106,16 +105,14 @@ public String getJson() {
106105
public BinaryTag getBinaryTag() {
107106
if (binaryTag == null) {
108107
// TODO: replace this with adventure-text-serializer-nbt
109-
binaryTag = serialize(GsonComponentSerializer.gson().serializeToTree(getComponent()));
108+
binaryTag = serialize(ProtocolUtils.getJsonChatSerializer(version).serializeToTree(getComponent()));
110109
}
111110
return binaryTag;
112111
}
113112

114113
public static BinaryTag serialize(JsonElement json) {
115-
if (json instanceof JsonPrimitive) {
116-
JsonPrimitive jsonPrimitive = (JsonPrimitive) json;
117-
118-
if (jsonPrimitive.isNumber()) {
114+
if (json instanceof JsonPrimitive jsonPrimitive) {
115+
if (jsonPrimitive.isNumber()) {
119116
Number number = json.getAsNumber();
120117

121118
if (number instanceof Byte) {

0 commit comments

Comments
 (0)