From 660246790b71d2e392799f81fab1275b4d2e36a2 Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Wed, 20 Nov 2024 21:05:47 +0100 Subject: [PATCH] Fix: Mineshaft roomId in Custom Scoreboard (#2946) --- .../java/at/hannibal2/skyhanni/data/MiningAPI.kt | 12 ++++++++++++ .../skyhanni/features/dungeon/DungeonAPI.kt | 2 +- .../elements/ScoreboardElementLobbyCode.kt | 12 ++++++++---- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt index c6e4895c4d35..8b0790c07e8f 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt @@ -14,6 +14,7 @@ import at.hannibal2.skyhanni.events.ServerBlockChangeEvent import at.hannibal2.skyhanni.events.mining.OreMinedEvent import at.hannibal2.skyhanni.events.player.PlayerDeathEvent import at.hannibal2.skyhanni.events.skyblock.ScoreboardAreaChangeEvent +import at.hannibal2.skyhanni.features.dungeon.DungeonAPI.dungeonRoomPattern import at.hannibal2.skyhanni.features.mining.OreBlock import at.hannibal2.skyhanni.features.mining.isTitanium import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule @@ -152,6 +153,9 @@ object MiningAPI { var cold: Int = 0 private set + var mineshaftRoomId: String? = null + private set + var lastColdUpdate = SimpleTimeMark.farPast() private set var lastColdReset = SimpleTimeMark.farPast() @@ -188,6 +192,14 @@ object MiningAPI { @SubscribeEvent fun onScoreboardChange(event: ScoreboardUpdateEvent) { + if (!inCustomMiningIsland()) return + + dungeonRoomPattern.firstMatcher(event.added) { + mineshaftRoomId = group("roomId") + } ?: run { + mineshaftRoomId = null + } + val newCold = coldPattern.firstMatcher(event.added) { group("cold").toInt().absoluteValue } ?: return 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 297ff968c9da..a12b202f405f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt @@ -97,7 +97,7 @@ object DungeonAPI { /** * REGEX-TEST: §711/15/24 §8m4F 830,-420 */ - private val dungeonRoomPattern by patternGroup.pattern( + val dungeonRoomPattern by patternGroup.pattern( "room", "§7\\d+/\\d+/\\d+ §\\w+ (?[\\w,-]+)", ) diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/elements/ScoreboardElementLobbyCode.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/elements/ScoreboardElementLobbyCode.kt index 5a69571295c7..0917bfb6ab61 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/elements/ScoreboardElementLobbyCode.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/elements/ScoreboardElementLobbyCode.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.gui.customscoreboard.elements import at.hannibal2.skyhanni.data.DateFormat import at.hannibal2.skyhanni.data.HypixelData +import at.hannibal2.skyhanni.data.MiningAPI import at.hannibal2.skyhanni.features.dungeon.DungeonAPI import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard @@ -9,10 +10,13 @@ import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard // update on island change and every second while in dungeons object ScoreboardElementLobbyCode : ScoreboardElement() { override fun getDisplay() = buildString { - if (CustomScoreboard.displayConfig.dateInLobbyCode) append("§7${CustomScoreboard.displayConfig.dateFormat} ") - HypixelData.serverId?.let { append("§8$it") } - DungeonAPI.roomId?.let { append(" §8$it") } - } + if (CustomScoreboard.displayConfig.dateInLobbyCode) append("§7${CustomScoreboard.displayConfig.dateFormat}") + listOfNotNull( + HypixelData.serverId, + DungeonAPI.roomId, + MiningAPI.mineshaftRoomId, + ).forEach { append(" §8$it") } + }.trim() override val configLine = "§7${DateFormat.US_SLASH_MMDDYYYY} §8mega77CK" }