diff options
author | CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> | 2024-04-05 05:46:27 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-04 20:46:27 +0200 |
commit | 15db91ced38a8cc4c7c16565422fce5566c6057c (patch) | |
tree | 487804f98d4cad7316ea8b4f0f033fe530b2c4a5 /src/main/java/at/hannibal2/skyhanni/features/dungeon | |
parent | 52afdbf62ef5c35403132696918b9cfcc8faffdb (diff) | |
download | skyhanni-15db91ced38a8cc4c7c16565422fce5566c6057c.tar.gz skyhanni-15db91ced38a8cc4c7c16565422fce5566c6057c.tar.bz2 skyhanni-15db91ced38a8cc4c7c16565422fce5566c6057c.zip |
Backend: matchFirst function for lists of strings (#1353)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/dungeon')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt index f0eca0fd9..1543aaf01 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt @@ -18,6 +18,7 @@ import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary +import at.hannibal2.skyhanni.utils.StringUtils.matchFirst import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.TabListData @@ -88,11 +89,8 @@ object DungeonAPI { } fun getTime(): String { - loop@ for (line in ScoreboardData.sidebarLinesFormatted) { - timePattern.matchMatcher(line.removeColor()) { - if (!matches()) continue@loop - return "${group("minutes") ?: "00"}:${group("seconds")}" // 03:14 - } + ScoreboardData.sidebarLinesFormatted.matchFirst(timePattern) { + return "${group("minutes") ?: "00"}:${group("seconds")}" // 03:14 } return "" } @@ -121,12 +119,10 @@ object DungeonAPI { @SubscribeEvent fun onTick(event: LorenzTickEvent) { if (dungeonFloor == null) { - for (line in ScoreboardData.sidebarLinesFormatted) { - floorPattern.matchMatcher(line) { - val floor = group("floor") - dungeonFloor = floor - DungeonEnterEvent(floor).postAndCatch() - } + ScoreboardData.sidebarLinesFormatted.matchFirst(floorPattern) { + val floor = group("floor") + dungeonFloor = floor + DungeonEnterEvent(floor).postAndCatch() } } if (dungeonFloor != null && playerClass == null) { |