Catch tag to json conversion exceptions

This commit is contained in:
Nassim Jahnke 2023-12-30 17:25:54 +01:00
parent bae3d8ec8a
commit 7b4d544e85
No known key found for this signature in database
GPG Key ID: EF6771C01F6EF02F

View File

@ -53,8 +53,13 @@ public final class ComponentUtil {
}
public static @Nullable JsonElement tagToJson(@Nullable final Tag tag) {
final ATextComponent component = TextComponentCodec.V1_20_3.deserializeNbtTree(tag);
return component != null ? SerializerVersion.V1_19_4.toJson(component) : null;
try {
final ATextComponent component = TextComponentCodec.V1_20_3.deserializeNbtTree(tag);
return component != null ? SerializerVersion.V1_19_4.toJson(component) : null;
} catch (final Exception e) {
Via.getPlatform().getLogger().log(Level.SEVERE, "Error converting tag: " + tag, e);
return plainToJson("<error>");
}
}
public static @Nullable Tag jsonToTag(@Nullable final JsonElement element) {