aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
authorJ10a1n15 <45315647+j10a1n15@users.noreply.github.com>2024-08-15 23:19:53 +0200
committerGitHub <noreply@github.com>2024-08-15 23:19:53 +0200
commitb0a8f0a0c712b606e20f0c9b36d65b4c8ce70c35 (patch)
treede2d09afa30a7b2121143837855c18b72698a6a6 /src/main/java/at/hannibal2
parent6716d23a43603ddd1bb92ccc71f80e37436828ce (diff)
downloadskyhanni-b0a8f0a0c712b606e20f0c9b36d65b4c8ce70c35.tar.gz
skyhanni-b0a8f0a0c712b606e20f0c9b36d65b4c8ce70c35.tar.bz2
skyhanni-b0a8f0a0c712b606e20f0c9b36d65b4c8ce70c35.zip
Fix: ScoreboardData and splitting (#2345)
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt10
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)