3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-27 08:30:09 +01:00

Catch tag to json conversion exceptions

Dieser Commit ist enthalten in:
Nassim Jahnke 2023-12-30 17:25:54 +01:00
Ursprung bae3d8ec8a
Commit 7b4d544e85
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: EF6771C01F6EF02F

Datei anzeigen

@ -53,8 +53,13 @@ public final class ComponentUtil {
} }
public static @Nullable JsonElement tagToJson(@Nullable final Tag tag) { public static @Nullable JsonElement tagToJson(@Nullable final Tag tag) {
try {
final ATextComponent component = TextComponentCodec.V1_20_3.deserializeNbtTree(tag); final ATextComponent component = TextComponentCodec.V1_20_3.deserializeNbtTree(tag);
return component != null ? SerializerVersion.V1_19_4.toJson(component) : null; 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) { public static @Nullable Tag jsonToTag(@Nullable final JsonElement element) {