File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
common/src/main/java/com/viaversion/viaversion/util Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 3030import net .lenni0451 .mcstructs .text .events .hover .impl .TextHoverEvent ;
3131import net .lenni0451 .mcstructs .text .serializer .LegacyStringDeserializer ;
3232import net .lenni0451 .mcstructs .text .serializer .TextComponentSerializer ;
33+ import net .lenni0451 .mcstructs .text .utils .TextUtils ;
3334import org .checkerframework .checker .nullness .qual .Nullable ;
3435
3536/**
@@ -151,12 +152,18 @@ public static String legacyToJsonString(final String message) {
151152
152153 public static String legacyToJsonString (final String message , final boolean itemData ) {
153154 final ATextComponent component = LegacyStringDeserializer .parse (message , true );
154- if (itemData ) {
155+ if (itemData && hasStyle ( component ) ) {
155156 component .setParentStyle (new Style ().setItalic (false ));
156157 }
157158 return SerializerVersion .V1_12 .toString (component );
158159 }
159160
161+ public static boolean hasStyle (final ATextComponent component ) {
162+ final boolean [] hasStyle = {false };
163+ TextUtils .iterateAll (component , c -> hasStyle [0 ] |= !c .getStyle ().isEmpty ());
164+ return hasStyle [0 ];
165+ }
166+
160167 public static String jsonToLegacy (final String value ) {
161168 return TextComponentSerializer .V1_12 .deserializeReader (value ).asLegacyFormatString ();
162169 }
You can’t perform that action at this time.
0 commit comments