aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorJ10a1n15 <45315647+j10a1n15@users.noreply.github.com>2024-04-05 18:34:56 +0200
committerGitHub <noreply@github.com>2024-04-05 18:34:56 +0200
commitbd34b28c14940a0d21a08057e944c7d55d91a1fd (patch)
treed533b4bdb56452d09db962ab880e5a5a90055c48 /src/main/java
parentf3c5a44c0a4d4cf23bd3d99b8e42255254514d53 (diff)
downloadskyhanni-bd34b28c14940a0d21a08057e944c7d55d91a1fd.tar.gz
skyhanni-bd34b28c14940a0d21a08057e944c7d55d91a1fd.tar.bz2
skyhanni-bd34b28c14940a0d21a08057e944c7d55d91a1fd.zip
Backend: Improved Scoreboard Line joining with special formatting codes (#1333)
Diffstat (limited to 'src/main/java')
-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 -> ""
}