From a6ecdbcb42572739d4290bbaca463956c66b20cb Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Sun, 15 Sep 2024 11:41:48 +0200 Subject: Improvement: Spade tracker visibility (#2496) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> --- .../features/event/diana/DianaProfitTracker.kt | 18 +++++++----- .../event/diana/MythologicalCreatureTracker.kt | 34 +++++++++++++--------- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaProfitTracker.kt index b6ec4d0a6..fb90de9e1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaProfitTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaProfitTracker.kt @@ -8,9 +8,11 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.ItemAddEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.features.event.diana.DianaAPI.isDianaSpade import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.addSearchString +import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators @@ -107,7 +109,7 @@ object DianaProfitTracker { @SubscribeEvent fun onItemAdd(event: ItemAddEvent) { - if (!isEnabled()) return + if (!(DianaAPI.isDoingDiana() && config.enabled)) return tryAddItem(event.internalName, event.amount, event.source == ItemAddManager.Source.COMMAND) } @@ -137,9 +139,7 @@ object DianaProfitTracker { tryHide(event) } - if (message == "§6§lRARE DROP! §r§eYou dug out a §r§9Griffin Feather§r§e!" || - message == "§eFollow the arrows to find the §r§6treasure§r§e!" - ) { + if (message == "§6§lRARE DROP! §r§eYou dug out a §r§9Griffin Feather§r§e!" || message == "§eFollow the arrows to find the §r§6treasure§r§e!") { BurrowAPI.lastBurrowRelatedChatMessage = SimpleTimeMark.now() tryHide(event) } @@ -153,7 +153,13 @@ object DianaProfitTracker { @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent) { - if (!isEnabled()) return + if (!LorenzUtils.inSkyBlock) return + if (!config.enabled) return + val spadeInHand = InventoryUtils.getItemInHand()?.isDianaSpade ?: false + if (!DianaAPI.isDoingDiana() && !spadeInHand) return + if (spadeInHand) { + tracker.firstUpdate() + } tracker.renderDisplay(config.position) } @@ -168,6 +174,4 @@ object DianaProfitTracker { fun resetCommand() { tracker.resetCommand() } - - private fun isEnabled() = DianaAPI.isDoingDiana() && config.enabled } diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/MythologicalCreatureTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/MythologicalCreatureTracker.kt index 3c512d4c4..55e422cab 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/MythologicalCreatureTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/MythologicalCreatureTracker.kt @@ -5,11 +5,13 @@ import at.hannibal2.skyhanni.data.MayorAPI.getElectionYear import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.features.event.diana.DianaAPI.isDianaSpade import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut import at.hannibal2.skyhanni.utils.CollectionUtils.addSearchString import at.hannibal2.skyhanni.utils.CollectionUtils.sumAllValues import at.hannibal2.skyhanni.utils.ConditionalUtils +import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.RegexUtils.matches @@ -90,19 +92,18 @@ object MythologicalCreatureTracker { @SubscribeEvent fun onChat(event: LorenzChatEvent) { for (creatureType in MythologicalCreatureType.entries) { - if (creatureType.pattern.matches(event.message)) { - BurrowAPI.lastBurrowRelatedChatMessage = SimpleTimeMark.now() - tracker.modify { - it.count.addOrPut(creatureType, 1) - - // TODO migrate to abstract feature in the future - if (creatureType == MythologicalCreatureType.MINOS_INQUISITOR) { - event.chatComponent = ChatComponentText(event.message + " §e(${it.creaturesSinceLastInquisitor})") - it.creaturesSinceLastInquisitor = 0 - } else it.creaturesSinceLastInquisitor++ - } - if (config.hideChat) event.blockedReason = "mythological_creature_dug" + if (!creatureType.pattern.matches(event.message)) continue + BurrowAPI.lastBurrowRelatedChatMessage = SimpleTimeMark.now() + tracker.modify { + it.count.addOrPut(creatureType, 1) + + // TODO migrate to abstract feature in the future + if (creatureType == MythologicalCreatureType.MINOS_INQUISITOR) { + event.chatComponent = ChatComponentText(event.message + " §e(${it.creaturesSinceLastInquisitor})") + it.creaturesSinceLastInquisitor = 0 + } else it.creaturesSinceLastInquisitor++ } + if (config.hideChat) event.blockedReason = "mythological_creature_dug" } } @@ -133,7 +134,13 @@ object MythologicalCreatureTracker { @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent) { - if (!isEnabled()) return + if (!LorenzUtils.inSkyBlock) return + if (!config.enabled) return + val spadeInHand = InventoryUtils.getItemInHand()?.isDianaSpade ?: false + if (!DianaAPI.isDoingDiana() && !spadeInHand) return + if (spadeInHand) { + tracker.firstUpdate() + } tracker.renderDisplay(config.position) } @@ -142,5 +149,4 @@ object MythologicalCreatureTracker { tracker.resetCommand() } - private fun isEnabled() = DianaAPI.isDoingDiana() && config.enabled } -- cgit