Skip to content

Commit 135e1ec

Browse files
authored
Reapply chat fixes for 1.18
Fixes #8 in the same way patch #9 works. Untested
1 parent aa81363 commit 135e1ec

File tree

1 file changed

+29
-25
lines changed

1 file changed

+29
-25
lines changed

src/main/java/io/github/techstreet/dfscript/util/ComponentUtil.java

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -55,35 +55,39 @@ public static MutableText fromString(String message) {
5555
public static String toFormattedString(Text message) {
5656
StringBuilder result = new StringBuilder();
5757

58-
Style style = message.getStyle();
58+
if(message.getSiblings().isEmpty()){
59+
Style style = message.getStyle();
5960

60-
String format = "";
61+
String format = "";
6162

62-
if (style.getColor() != null) {
63-
format += "§x§" + String.join("§", String.format("%06X", style.getColor().getRgb()).split(""));
64-
}
65-
66-
if (style.isBold()) {
67-
format += "§l";
68-
}
69-
if (style.isItalic()) {
70-
format += "§o";
71-
}
72-
if (style.isUnderlined()) {
73-
format += "§n";
74-
}
75-
if (style.isStrikethrough()) {
76-
format += "§m";
77-
}
78-
if (style.isObfuscated()) {
79-
format += "§k";
80-
}
63+
if (style.getColor() != null) {
64+
format += "§x§" + String.join("§", String.format("%06X", style.getColor().getRgb()).split(""));
65+
}
8166

82-
result.append(format);
83-
result.append(message.getString());
67+
if (style.isBold()) {
68+
format += "§l";
69+
}
70+
if (style.isItalic()) {
71+
format += "§o";
72+
}
73+
if (style.isUnderlined()) {
74+
format += "§n";
75+
}
76+
if (style.isStrikethrough()) {
77+
format += "§m";
78+
}
79+
if (style.isObfuscated()) {
80+
format += "§k";
81+
}
8482

85-
for (Text sibling : message.getSiblings()) {
86-
result.append(toFormattedString(sibling));
83+
result.append(format);
84+
result.append(message.getString());
85+
}
86+
else {
87+
for (Text sibling : message.getSiblings()) {
88+
result.append("§r");
89+
result.append(toFormattedString(sibling));
90+
}
8791
}
8892

8993
return result.toString();

0 commit comments

Comments
 (0)