legacy <-> json changes

This commit is contained in:
Auxilor
2021-12-26 16:34:52 +00:00
parent 623b8a18f4
commit 804f187964

View File

@@ -58,6 +58,13 @@ public final class StringUtils {
.hexColors()
.build();
/**
* GSON serializer.
*/
private static final GsonComponentSerializer GSON_COMPONENT_SERIALIZER = GsonComponentSerializer.builder()
.emitLegacyHoverEvent()
.build();
/**
* Color map.
*/
@@ -415,7 +422,7 @@ public final class StringUtils {
if (legacy == null) {
processed = "";
}
return GsonComponentSerializer.gson().serialize(
return GSON_COMPONENT_SERIALIZER.serialize(
Component.empty().decoration(TextDecoration.ITALIC, false).append(
LEGACY_COMPONENT_SERIALIZER.deserialize(processed)
)
@@ -431,7 +438,7 @@ public final class StringUtils {
@NotNull
public static String jsonToLegacy(@NotNull final String json) {
return LEGACY_COMPONENT_SERIALIZER.serialize(
GsonComponentSerializer.gson().deserialize(json)
GSON_COMPONENT_SERIALIZER.deserialize(json)
);
}