diff options
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonRankTabListColor.kt | 32 |
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)" } } |