aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt b/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt
index b2cb66ef0..a18dbf502 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt
@@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.data
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.ScoreboardChangeEvent
import at.hannibal2.skyhanni.events.ScoreboardRawChangeEvent
+import at.hannibal2.skyhanni.utils.StringUtils.matches
import net.minecraft.client.Minecraft
import net.minecraft.scoreboard.Score
import net.minecraft.scoreboard.ScorePlayerTeam
@@ -13,6 +14,9 @@ class ScoreboardData {
companion object {
+ private val minecraftColorCodesPattern = "(?i)[0-9a-fkmolnr]".toPattern()
+
+
// TODO USE SH-REPO
private val splitIcons = listOf(
"\uD83C\uDF6B",
@@ -42,10 +46,14 @@ class ScoreboardData {
// get last color code in start
val lastColorIndex = start.lastIndexOf('ยง')
val lastColor = when {
- lastColorIndex != -1 && lastColorIndex + 1 < start.length && (start[lastColorIndex + 1] in '0'..'9' || start[lastColorIndex + 1] in 'a'..'f') -> start.substring(
+ lastColorIndex != -1
+ && lastColorIndex + 1 < start.length
+ && (minecraftColorCodesPattern.matches( start[lastColorIndex + 1].toString()))
+ -> start.substring(
lastColorIndex,
lastColorIndex + 2
)
+
else -> ""
}