diff --git a/Plan/common/src/main/java/com/djrapitops/plan/utilities/html/Html.java b/Plan/common/src/main/java/com/djrapitops/plan/utilities/html/Html.java index dcce06ef5..895516579 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/utilities/html/Html.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/utilities/html/Html.java @@ -135,12 +135,19 @@ public enum Html { StringBuilder result = new StringBuilder(string.length()); String[] split = string.split("§"); + // Skip first part if it does not start with § + boolean skipFirst = !string.startsWith("§"); int placedSpans = 0; for (String part : split) { if (part.isEmpty()) { continue; } + if (skipFirst) { + result.append(part); + skipFirst = false; + continue; + } char colorChar = part.charAt(0); if (colorChar == 'r') { diff --git a/Plan/common/src/test/java/com/djrapitops/plan/utilities/html/HtmlTest.java b/Plan/common/src/test/java/com/djrapitops/plan/utilities/html/HtmlTest.java index 6a1d19973..2bdbb2e09 100644 --- a/Plan/common/src/test/java/com/djrapitops/plan/utilities/html/HtmlTest.java +++ b/Plan/common/src/test/java/com/djrapitops/plan/utilities/html/HtmlTest.java @@ -53,4 +53,12 @@ class HtmlTest { String result = Html.swapColorCodesToSpan(testString); assertEquals(expected, result); } + + @Test + void swapColorCodesDoesNotReplaceNonColors() { + String testString = "1test§2yes"; + String expected = "1test" + Html.COLOR_2.parse() + "yes"; + String result = Html.swapColorCodesToSpan(testString); + assertEquals(expected, result); + } }