From 804f1879644e384bdf3232326d74e036f76ddb7f Mon Sep 17 00:00:00 2001 From: Auxilor Date: Sun, 26 Dec 2021 16:34:52 +0000 Subject: [PATCH] legacy <-> json changes --- .../main/java/com/willfp/eco/util/StringUtils.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/eco-api/src/main/java/com/willfp/eco/util/StringUtils.java b/eco-api/src/main/java/com/willfp/eco/util/StringUtils.java index 00a4cf4e..e94c6bf6 100644 --- a/eco-api/src/main/java/com/willfp/eco/util/StringUtils.java +++ b/eco-api/src/main/java/com/willfp/eco/util/StringUtils.java @@ -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) ); }