From 868e7f4102e8d54ce6904a1b2cabcae3d32ad37d Mon Sep 17 00:00:00 2001 From: Stefan923 Date: Fri, 8 May 2020 20:27:03 +0300 Subject: [PATCH] Method weren't formatting both color and style to the same text. --- .../factions/zcore/util/TextUtil.java | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/zcore/util/TextUtil.java b/src/main/java/com/massivecraft/factions/zcore/util/TextUtil.java index 95509f98..1b271c0d 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/TextUtil.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/TextUtil.java @@ -47,33 +47,41 @@ public class TextUtil { String text = ""; FancyMessage message = new FancyMessage(text); ChatColor color = null; + ChatColor style = null; char[] chars = first.toCharArray(); for (int i = 0; i < chars.length; i++) { // changed this so javadocs wont throw an error String compareChar = chars[i] + ""; if (compareChar.equals("ยง")) { - if (color != null) { - if (color.isColor()) { - message.then(text).color(color); - } else { - message.then(text).style(color); + if (color != null || style != null) { + message.then(text); + if (color != null) + message.color(color); + if (style != null) { + message.style(style); + style = null; } 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 } else { text += chars[i]; } } if (text.length() > 0) { - if (color != null) { - if (color.isColor()) { - message.then(text).color(color); - } else { - message.then(text).style(color); - } + if (color != null || style != null) { + message.then(text); + if (color != null) + message.color(color); + if (style != null) + message.style(style); } else { message.text(text); }