Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-20 06:50:08 +01:00
Handle edge cases when converting legacy components (#3896)
Dieser Commit ist enthalten in:
Ursprung
d4034792c4
Commit
2a088c08ed
@ -155,18 +155,16 @@ public final class ComponentUtil {
|
||||
|
||||
public static String legacyToJsonString(final String message, final boolean itemData) {
|
||||
final ATextComponent component = LegacyStringDeserializer.parse(message, true);
|
||||
if (itemData && hasStyle(component)) {
|
||||
component.setParentStyle(new Style().setItalic(false));
|
||||
if (itemData) {
|
||||
TextUtils.iterateAll(component, c -> {
|
||||
if (!c.getStyle().isEmpty()) {
|
||||
c.setParentStyle(new Style().setItalic(false));
|
||||
}
|
||||
});
|
||||
}
|
||||
return SerializerVersion.V1_12.toString(component);
|
||||
}
|
||||
|
||||
public static boolean hasStyle(final ATextComponent component) {
|
||||
final boolean[] hasStyle = {false};
|
||||
TextUtils.iterateAll(component, c -> hasStyle[0] |= !c.getStyle().isEmpty());
|
||||
return hasStyle[0];
|
||||
}
|
||||
|
||||
public static String jsonToLegacy(final String value) {
|
||||
return TextComponentSerializer.V1_12.deserializeReader(value).asLegacyFormatString();
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren