Check for suppress conversion warnings option in ComponentUtil functions

This commit is contained in:
FlorianMichael 2024-10-22 22:31:17 +02:00
parent c242456c30
commit 94b26a903c
2 changed files with 10 additions and 4 deletions

View File

@ -60,7 +60,9 @@ public final class ComponentUtil {
final ATextComponent component = SerializerVersion.V1_20_3.toComponent(tag);
return component != null ? SerializerVersion.V1_19_4.toJson(component) : null;
} catch (final Exception e) {
if (!Via.getConfig().isSuppressConversionWarnings()) {
Via.getPlatform().getLogger().log(Level.SEVERE, "Error converting tag: " + tag, e);
}
return plainToJson("<error>");
}
}
@ -74,7 +76,9 @@ public final class ComponentUtil {
final ATextComponent component = SerializerVersion.V1_19_4.toComponent(element);
return trimStrings(SerializerVersion.V1_20_3.toTag(component));
} catch (final Exception e) {
if (!Via.getConfig().isSuppressConversionWarnings()) {
Via.getPlatform().getLogger().log(Level.SEVERE, "Error converting component: " + element, e);
}
return new StringTag("<error>");
}
}
@ -101,7 +105,9 @@ public final class ComponentUtil {
final ATextComponent component = SerializerVersion.V1_20_5.toComponent(tag);
return component != null ? SerializerVersion.V1_20_3.toString(component) : null;
} catch (final Exception e) {
if (!Via.getConfig().isSuppressConversionWarnings()) {
Via.getPlatform().getLogger().log(Level.SEVERE, "Error converting tag: " + tag, e);
}
return plainToJson("<error>").toString();
}
}

View File

@ -25,7 +25,7 @@ block-disconnect-msg: "You are using an unsupported Minecraft version!"
# (We don't suggest using reload either, use a plugin manager)
# You can customize the message we kick people with if you use ProtocolLib here.
reload-disconnect-msg: "Server reload, please rejoin!"
# We warn when there's an error converting item and block data over versions, should we suppress these? (Only suggested if spamming)
# We warn when there's an error converting item/block or component/nbt data over versions, should we suppress these? (Only suggested if spamming)
suppress-conversion-warnings: false
#
#----------------------------------------------------------#