diff --git a/src/main/java/io/github/techstreet/dfscript/util/ComponentUtil.java b/src/main/java/io/github/techstreet/dfscript/util/ComponentUtil.java index f350535..c464aae 100644 --- a/src/main/java/io/github/techstreet/dfscript/util/ComponentUtil.java +++ b/src/main/java/io/github/techstreet/dfscript/util/ComponentUtil.java @@ -55,35 +55,39 @@ public static MutableText fromString(String message) { public static String toFormattedString(Text message) { StringBuilder result = new StringBuilder(); - Style style = message.getStyle(); + if(message.getSiblings().isEmpty()){ + Style style = message.getStyle(); - String format = ""; + String format = ""; - if (style.getColor() != null) { - format += "§x§" + String.join("§", String.format("%06X", style.getColor().getRgb()).split("")); - } - - if (style.isBold()) { - format += "§l"; - } - if (style.isItalic()) { - format += "§o"; - } - if (style.isUnderlined()) { - format += "§n"; - } - if (style.isStrikethrough()) { - format += "§m"; - } - if (style.isObfuscated()) { - format += "§k"; - } + if (style.getColor() != null) { + format += "§x§" + String.join("§", String.format("%06X", style.getColor().getRgb()).split("")); + } - result.append(format); - result.append(message.getString()); + if (style.isBold()) { + format += "§l"; + } + if (style.isItalic()) { + format += "§o"; + } + if (style.isUnderlined()) { + format += "§n"; + } + if (style.isStrikethrough()) { + format += "§m"; + } + if (style.isObfuscated()) { + format += "§k"; + } - for (Text sibling : message.getSiblings()) { - result.append(toFormattedString(sibling)); + result.append(format); + result.append(message.getString()); + } + else { + for (Text sibling : message.getSiblings()) { + result.append("§r"); + result.append(toFormattedString(sibling)); + } } return result.toString();