aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
authorEmpa <42304516+ItsEmpa@users.noreply.github.com>2024-05-25 09:40:09 +0200
committerGitHub <noreply@github.com>2024-05-25 09:40:09 +0200
commit6a46a2fcd6495293a3357117b1d53eb8873f047d (patch)
tree3b22e3f87b6857a8af97ce2d10ef0522f8fcc2df /src/main/java/at/hannibal2
parent2ce69d656479050e382be5a5722bc74a4ca9e3c8 (diff)
downloadskyhanni-6a46a2fcd6495293a3357117b1d53eb8873f047d.tar.gz
skyhanni-6a46a2fcd6495293a3357117b1d53eb8873f047d.tar.bz2
skyhanni-6a46a2fcd6495293a3357117b1d53eb8873f047d.zip
Fix: Dungeon Rank Tablist Color (#1878)
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonRankTabListColor.kt32
1 files changed, 22 insertions, 10 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonRankTabListColor.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonRankTabListColor.kt
index 3e0a719fa..b12b99ca0 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonRankTabListColor.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonRankTabListColor.kt
@@ -2,31 +2,43 @@ package at.hannibal2.skyhanni.features.dungeon
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.TabListLineRenderEvent
-import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal
+import at.hannibal2.skyhanni.utils.LorenzUtils.groupOrNull
+import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary
import at.hannibal2.skyhanni.utils.StringUtils.cleanPlayerName
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.StringUtils.stripHypixelMessage
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class DungeonRankTabListColor {
private val config get() = SkyHanniMod.feature.dungeon.tabList
- private val pattern = "§r(?<playerName>.*) §r§f\\(§r§d(?<className>.*) (?<classLevel>.*)§r§f\\)§r".toPattern()
+ private val patternGroup = RepoPattern.group("dungeon.tablist")
+
+ /**
+ * REGEX-TEST: §8[§r§9319§r§8] §r§bEmpa_ §r§7α §r§f(§r§dMage XXXIV§r§f)
+ */
+ private val pattern by patternGroup.pattern(
+ "rank",
+ "^(?:§.)*(?<sbLevel>\\[(?:§.)*\\d+(?:§.)*]) (?<rank>(?:§.)*\\[(?:§.)*[^]]+(?:§.)*])? ?(?<playerName>\\S+) (?<symbols>[^(]*)\\((?:§.)*(?<className>\\S+) (?<classLevel>[CLXVI]+)(?:§.)*\\)(?:§.)*$"
+ )
@SubscribeEvent
fun onTabListText(event: TabListLineRenderEvent) {
if (!isEnabled()) return
- pattern.matchMatcher(event.text) {
+ pattern.matchMatcher(event.text.stripHypixelMessage()) {
+ val sbLevel = group("sbLevel")
+ val rank = groupOrNull("rank") ?: ""
val playerName = group("playerName")
- val split = playerName.split(" ")
- val sbLevel = split[0]
- val cleanName = split[1].cleanPlayerName(displayName = true)
-
+ //val symbols = group("symbols")
val className = group("className")
- val level = group("classLevel").romanToDecimal()
- val color = DungeonAPI.getColor(level)
+ val classLevel = group("classLevel")
+
+ val cleanName = playerName.cleanPlayerName(true)
+ val color = DungeonAPI.getColor(classLevel.romanToDecimalIfNecessary())
- event.text = "$sbLevel $cleanName §7(§e$className $color$level§7)"
+ event.text = "§8$sbLevel $rank$cleanName §f(§d$className $color$classLevel§f)"
}
}