Method weren't formatting both color and style to the same text.

This commit is contained in:
Stefan923 2020-05-08 20:27:03 +03:00 committed by BrowkS
parent d8b08ef6d7
commit 868e7f4102

View File

@ -47,33 +47,41 @@ public class TextUtil {
String text = ""; String text = "";
FancyMessage message = new FancyMessage(text); FancyMessage message = new FancyMessage(text);
ChatColor color = null; ChatColor color = null;
ChatColor style = null;
char[] chars = first.toCharArray(); char[] chars = first.toCharArray();
for (int i = 0; i < chars.length; i++) { for (int i = 0; i < chars.length; i++) {
// changed this so javadocs wont throw an error // changed this so javadocs wont throw an error
String compareChar = chars[i] + ""; String compareChar = chars[i] + "";
if (compareChar.equals("§")) { if (compareChar.equals("§")) {
if (color != null) { if (color != null || style != null) {
if (color.isColor()) { message.then(text);
message.then(text).color(color); if (color != null)
} else { message.color(color);
message.then(text).style(color); if (style != null) {
message.style(style);
style = null;
} }
text = ""; text = "";
} }
color = ChatColor.getByChar(chars[i + 1]); ChatColor tempColor = ChatColor.getByChar(chars[i + 1]);
if (tempColor.isColor()) {
color = tempColor;
} else {
style = tempColor;
}
i++; // skip color char i++; // skip color char
} else { } else {
text += chars[i]; text += chars[i];
} }
} }
if (text.length() > 0) { if (text.length() > 0) {
if (color != null) { if (color != null || style != null) {
if (color.isColor()) { message.then(text);
message.then(text).color(color); if (color != null)
} else { message.color(color);
message.then(text).style(color); if (style != null)
} message.style(style);
} else { } else {
message.text(text); message.text(text);
} }