Use correct component serializer in ComponentHolder#getBinaryTag
This commit is contained in:
@@ -43,7 +43,6 @@ import net.kyori.adventure.nbt.LongBinaryTag;
|
|||||||
import net.kyori.adventure.nbt.ShortBinaryTag;
|
import net.kyori.adventure.nbt.ShortBinaryTag;
|
||||||
import net.kyori.adventure.nbt.StringBinaryTag;
|
import net.kyori.adventure.nbt.StringBinaryTag;
|
||||||
import net.kyori.adventure.text.Component;
|
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.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||||
@@ -106,16 +105,14 @@ public class ComponentHolder {
|
|||||||
public BinaryTag getBinaryTag() {
|
public BinaryTag getBinaryTag() {
|
||||||
if (binaryTag == null) {
|
if (binaryTag == null) {
|
||||||
// TODO: replace this with adventure-text-serializer-nbt
|
// TODO: replace this with adventure-text-serializer-nbt
|
||||||
binaryTag = serialize(GsonComponentSerializer.gson().serializeToTree(getComponent()));
|
binaryTag = serialize(ProtocolUtils.getJsonChatSerializer(version).serializeToTree(getComponent()));
|
||||||
}
|
}
|
||||||
return binaryTag;
|
return binaryTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BinaryTag serialize(JsonElement json) {
|
public static BinaryTag serialize(JsonElement json) {
|
||||||
if (json instanceof JsonPrimitive) {
|
if (json instanceof JsonPrimitive jsonPrimitive) {
|
||||||
JsonPrimitive jsonPrimitive = (JsonPrimitive) json;
|
if (jsonPrimitive.isNumber()) {
|
||||||
|
|
||||||
if (jsonPrimitive.isNumber()) {
|
|
||||||
Number number = json.getAsNumber();
|
Number number = json.getAsNumber();
|
||||||
|
|
||||||
if (number instanceof Byte) {
|
if (number instanceof Byte) {
|
||||||
|
Reference in New Issue
Block a user