aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJ10a1n15 <45315647+j10a1n15@users.noreply.github.com>2024-06-13 22:52:49 +0200
committerGitHub <noreply@github.com>2024-06-13 22:52:49 +0200
commita2d17be9e0fa7155aab1990cb5969ced6305ba1b (patch)
treeae573ab4df770b0d8a3ec3a508e3ac54bc4a6e3d /src
parent9deda23619394fa2be1439ab7912565467955a0a (diff)
downloadskyhanni-a2d17be9e0fa7155aab1990cb5969ced6305ba1b.tar.gz
skyhanni-a2d17be9e0fa7155aab1990cb5969ced6305ba1b.tar.bz2
skyhanni-a2d17be9e0fa7155aab1990cb5969ced6305ba1b.zip
Fix: Elapsed Time in Dungeons DiscordRPC (#2089)
Signed-off-by: J10a1n15 <45315647+j10a1n15@users.noreply.github.com>
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt34
1 files changed, 20 insertions, 14 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 e79abbe7c..b6d1ba219 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt
@@ -22,6 +22,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
import at.hannibal2.skyhanni.utils.NumberUtil.formatInt
import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary
+import at.hannibal2.skyhanni.utils.RegexUtils.groupOrNull
import at.hannibal2.skyhanni.utils.RegexUtils.matchFirst
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.RegexUtils.matches
@@ -55,26 +56,33 @@ object DungeonAPI {
var isUniqueClass = false
val bossStorage: MutableMap<DungeonFloor, Int>? get() = ProfileStorageData.profileSpecific?.dungeons?.bosses
- private val timePattern =
- "Time Elapsed:( )?(?:(?<minutes>\\d+)m)? (?<seconds>\\d+)s".toPattern() // Examples: Time Elapsed: 10m 10s, Time Elapsed: 2s
private val patternGroup = RepoPattern.group("dungeon")
+ /**
+ * REGEX-TEST: Time Elapsed: §a01m 17s
+ * REGEX-TEST: Time Elapsed: §a14s
+ */
+ private val timePattern by patternGroup.pattern(
+ "time",
+ "Time Elapsed: §.(?:(?<minutes>\\d+)m )?(?<seconds>\\d+)s",
+ )
+
private val dungeonComplete by patternGroup.pattern(
"complete",
- "§.\\s+§.§.(?:The|Master Mode) Catacombs §.§.- §.§.(?:Floor )?(?<floor>M?[IV]{1,3}|Entrance)"
+ "§.\\s+§.§.(?:The|Master Mode) Catacombs §.§.- §.§.(?:Floor )?(?<floor>M?[IV]{1,3}|Entrance)",
)
private val dungeonRoomPattern by patternGroup.pattern(
"room",
- "§7\\d+\\/\\d+\\/\\d+ §\\w+ (?<roomId>[\\w,-]+)"
+ "§7\\d+\\/\\d+\\/\\d+ §\\w+ (?<roomId>[\\w,-]+)",
)
private val blessingPattern by patternGroup.pattern(
"blessings",
- "§r§r§fBlessing of (?<type>\\w+) (?<amount>\\w+)§r"
+ "§r§r§fBlessing of (?<type>\\w+) (?<amount>\\w+)§r",
)
private val noBlessingPattern by patternGroup.pattern(
"noblessings",
- "§r§r§7No Buffs active. Find them by exploring the Dungeon!§r"
+ "§r§r§7No Buffs active. Find them by exploring the Dungeon!§r",
)
enum class DungeonBlessings(var power: Int) {
@@ -124,12 +132,10 @@ object DungeonAPI {
return bossName.endsWith(correctBoss)
}
- fun getTime(): String {
+ fun getTime(): String =
ScoreboardData.sidebarLinesFormatted.matchFirst(timePattern) {
- return "${group("minutes") ?: "00"}:${group("seconds")}" // 03:14
- }
- return ""
- }
+ "${groupOrNull("minutes") ?: "00"}:${group("seconds")}"
+ } ?: ""
fun getCurrentBoss(): DungeonFloor? {
val floor = dungeonFloor ?: return null
@@ -320,8 +326,8 @@ object DungeonAPI {
add("playerClassLevel: $playerClassLevel")
add("")
add("Blessings: ")
- for (blessing in DungeonBlessings.entries) {
- add(" ${blessing.displayName} ${blessing.power}")
+ DungeonBlessings.entries.forEach {
+ add(" ${it.displayName} ${it.power}")
}
}
}
@@ -331,7 +337,7 @@ object DungeonAPI {
BERSERK("Berserk"),
HEALER("Healer"),
MAGE("Mage"),
- TANK("Tank")
+ TANK("Tank"),
}
enum class DungeonChest(val inventory: String) {