mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-09-18 17:51:01 +02:00
Fixed color parsing eating first character
Fixes a bug where first character of nickname or DataExtension String was removed if it started with of 1-9, a-f & r
This commit is contained in:
parent
710f8ec5bd
commit
8f639f7f41
@ -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') {
|
||||
|
@ -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</span>";
|
||||
String result = Html.swapColorCodesToSpan(testString);
|
||||
assertEquals(expected, result);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user