diff --git a/util/src/main/java/tc/oc/pgm/util/text/TextParser.java b/util/src/main/java/tc/oc/pgm/util/text/TextParser.java index e5fdfa014f..7adb68b0ca 100644 --- a/util/src/main/java/tc/oc/pgm/util/text/TextParser.java +++ b/util/src/main/java/tc/oc/pgm/util/text/TextParser.java @@ -434,6 +434,8 @@ public static Component parseComponent(String text) throws TextException { * *

Accepts legacy formatting with "ยง" as the color character. * + *

Accepts full qualified json strings as components. + * *

This method is mainly for backwards compatability for {@link * XMLUtils#parseFormattedText(Node, Component)}. Previously using {@link #parseComponent(String)} * with the result from {@code parseFormattedText} would bug out when sent to older clients, since @@ -442,10 +444,19 @@ public static Component parseComponent(String text) throws TextException { * * @param text The text. * @return a Component. + * @throws TextException If there is json present and it is invalid. */ public static Component parseComponentSection(String text) { checkNotNull(text, "cannot parse component from null"); + if (text.startsWith("{\"") && text.endsWith("\"}")) { + try { + return GsonComponentSerializer.gson().deserialize(text); + } catch (JsonSyntaxException e) { + throw invalidFormat(text, Component.class, e); + } + } + return LegacyComponentSerializer.legacySection().deserialize(text); }