diff options
author | martimavocado <39881008+martimavocado@users.noreply.github.com> | 2024-10-05 08:31:56 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-05 10:31:56 +0200 |
commit | 524df8b718cad70c7a7fc02e323721c85385d41b (patch) | |
tree | 21f4991d561974debab1708995dc4c51afb26c50 /src/main/java | |
parent | 9f9e11b88620047e98d12b609d6aca7d57760e31 (diff) | |
download | skyhanni-524df8b718cad70c7a7fc02e323721c85385d41b.tar.gz skyhanni-524df8b718cad70c7a7fc02e323721c85385d41b.tar.bz2 skyhanni-524df8b718cad70c7a7fc02e323721c85385d41b.zip |
Fix: Stop king talisman tracker on finish (#2663)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt | 47 |
1 files changed, 40 insertions, 7 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt index 057d2f476..b9f205984 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt @@ -2,9 +2,11 @@ package at.hannibal2.skyhanni.features.mining import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.data.MiningAPI import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent +import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils @@ -16,6 +18,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher +import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings import at.hannibal2.skyhanni.utils.SkyBlockTime import at.hannibal2.skyhanni.utils.TimeUtils.format @@ -31,11 +34,27 @@ object KingTalismanHelper { private val config get() = SkyHanniMod.feature.mining.kingTalisman private val storage get() = ProfileStorageData.profileSpecific?.mining - private val kingPattern by RepoPattern.pattern( - "mining.kingtalisman.king", + private val patternGroup = RepoPattern.group("mining.kingtalisman") + + /** + * REGEX-TEST: §6§lKing Brammor + * REGEX-TEST: §6§lKing Emkam + * REGEX-TEST: §6§lKing Kevin + * REGEX-TEST: §6§lKing Redros + */ + private val kingPattern by patternGroup.pattern( + "king", "§6§lKing (?<name>.*)" ) + /** + * REGEX-TEST: §7You have received a §r§fKing Talisman§r§7! + */ + private val talismanPattern by patternGroup.pattern( + "talisman", + "§7You have received a §r§fKing Talisman§r§7!" + ) + private var currentOffset: Int? = null private var skyblockYear = 0 @@ -66,7 +85,8 @@ object KingTalismanHelper { private var farDisplay = "" private var display = emptyList<String>() - private fun isNearby() = IslandType.DWARVEN_MINES.isInIsland() && LorenzUtils.skyBlockArea == "Royal Palace" && + private fun isNearby() = IslandType.DWARVEN_MINES.isInIsland() && + LorenzUtils.skyBlockArea == "Royal Palace" && kingLocation.distanceToPlayer() < 10 @SubscribeEvent @@ -86,7 +106,7 @@ object KingTalismanHelper { return } - update(kingsTalkedTo) + update() display = if (nearby) allKingsDisplay else Collections.singletonList(farDisplay) } @@ -103,7 +123,8 @@ object KingTalismanHelper { skyblockYear = SkyBlockTime.now().year } - fun isEnabled() = config.enabled && LorenzUtils.inSkyBlock && + fun isEnabled() = config.enabled && + LorenzUtils.inSkyBlock && (IslandType.DWARVEN_MINES.isInIsland() || config.outsideMines) @SubscribeEvent @@ -118,12 +139,13 @@ object KingTalismanHelper { val kingsTalkedTo = storage.kingsTalkedTo if (currentKing !in kingsTalkedTo) { kingsTalkedTo.add(currentKing) - update(kingsTalkedTo) + update() display = allKingsDisplay } } - private fun update(kingsTalkedTo: MutableList<String>) { + private fun update() { + val kingsTalkedTo = storage?.kingsTalkedTo ?: return if (kingsTalkedTo.size == kingCircles.size) { allKingsDisplay = Collections.singletonList("§eAll Kings found.") farDisplay = "" @@ -198,4 +220,15 @@ object KingTalismanHelper { config.position.renderStrings(display, posLabel = "King Talisman Helper") } + + @SubscribeEvent + fun onChat(event: LorenzChatEvent) { + if (!isEnabled()) return + if (!MiningAPI.inDwarvenMines) return + + if (talismanPattern.matches(event.message)) { + storage?.kingsTalkedTo = kingCircles.toMutableList() + update() + } + } } |