aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/dungeon
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-04-28 20:43:18 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-04-28 20:43:29 +0200
commitbd6a0bb93ed6c0499cc3c5e044b7554481825bb5 (patch)
treebe2eea214952108ae8acd658f4646403129a3e28 /src/main/java/at/hannibal2/skyhanni/features/dungeon
parent9df04ac5aaa5e9897324af306dc73b8b1e67f600 (diff)
downloadskyhanni-bd6a0bb93ed6c0499cc3c5e044b7554481825bb5.tar.gz
skyhanni-bd6a0bb93ed6c0499cc3c5e044b7554481825bb5.tar.bz2
skyhanni-bd6a0bb93ed6c0499cc3c5e044b7554481825bb5.zip
REGEX
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/dungeon')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonData.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLevelColor.kt18
2 files changed, 13 insertions, 14 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonData.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonData.kt
index 00db6d6b8..230e80dd2 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonData.kt
@@ -5,14 +5,14 @@ import at.hannibal2.skyhanni.events.DungeonBossRoomEnterEvent
import at.hannibal2.skyhanni.events.DungeonEnterEvent
import at.hannibal2.skyhanni.events.DungeonStartEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import net.minecraftforge.event.world.WorldEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.TickEvent
class DungeonData {
-
- private val pattern = " §7⏣ §cThe Catacombs §7\\((.*)\\)".toPattern()
+ private val floorPattern = " §7⏣ §cThe Catacombs §7\\((?<floor>.*)\\)".toPattern()
companion object {
var dungeonFloor: String? = null
@@ -66,9 +66,8 @@ class DungeonData {
if (event.phase != TickEvent.Phase.START) return
if (dungeonFloor == null) {
for (line in ScoreboardData.sidebarLinesFormatted) {
- val matcher = pattern.matcher(line)
- if (matcher.matches()) {
- val floor = matcher.group(1)
+ floorPattern.matchMatcher(line) {
+ val floor = group("floor")
dungeonFloor = floor
DungeonEnterEvent(floor).postAndCatch()
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLevelColor.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLevelColor.kt
index 91b347145..4f5ca684f 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLevelColor.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLevelColor.kt
@@ -4,12 +4,12 @@ import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import net.minecraftforge.event.entity.player.ItemTooltipEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class DungeonLevelColor {
-
- private val pattern = " §.(.*)§f: §e(.*)§b \\(§e(.*)§b\\)".toPattern()
+ private val pattern = " §.(?<playerName>.*)§f: §e(?<className>.*)§b \\(§e(?<level>.*)§b\\)".toPattern()
@SubscribeEvent
fun onItemTooltip(event: ItemTooltipEvent) {
@@ -24,14 +24,14 @@ class DungeonLevelColor {
var index = 0
for (line in stack.getLore()) {
index++
- val matcher = pattern.matcher(line)
- if (!matcher.matches()) continue
- val playerName = matcher.group(1)
- val className = matcher.group(2)
- val level = matcher.group(3).toInt()
- val color = getColor(level)
- event.toolTip[index] = " §b$playerName§f: §e$className $color$level"
+ pattern.matchMatcher(line) {
+ val playerName = group("playerName")
+ val className = group("className")
+ val level = group("level").toInt()
+ val color = getColor(level)
+ event.toolTip[index] = " §b$playerName§f: §e$className $color$level"
+ }
}
}