diff options
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt b/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt index 0ade6a946..a403db112 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt @@ -35,8 +35,14 @@ object ScoreboardData { val lastColor = start.lastColorCode() ?: "" - if (end.startsWith(lastColor)) { - end = end.removePrefix(lastColor) + // Determine the longest prefix of "end" that matches any suffix of "lastColor" + val colorSuffixes = generateSequence(lastColor) { it.dropLast(2) } + .takeWhile { it.isNotEmpty() } + .toList() + + val matchingPrefix = colorSuffixes.find { end.startsWith(it) } ?: "" + if (matchingPrefix.isNotEmpty()) { + end = end.removePrefix(matchingPrefix) } add(start + end) |