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) ); }