diff options
author | martimavocado <39881008+martimavocado@users.noreply.github.com> | 2024-01-23 15:35:36 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-23 16:35:36 +0100 |
commit | 6bd39d3c74563ba3a4abb5ee4b2b3f94e70a2f12 (patch) | |
tree | df98b13f8d3443c7b32b9c0d97285645d699409a /src/main/java | |
parent | aa0e27f12d7a2063e82611872cfd3b7dea26b462 (diff) | |
download | skyhanni-6bd39d3c74563ba3a4abb5ee4b2b3f94e70a2f12.tar.gz skyhanni-6bd39d3c74563ba3a4abb5ee4b2b3f94e70a2f12.tar.bz2 skyhanni-6bd39d3c74563ba3a4abb5ee4b2b3f94e70a2f12.zip |
Feature: Hide SC Tracker when wearing Trophy Hunter armor (#929)
Hide SC Tracker when wearing Trophy Hunter armor. #929
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/SeaCreatureTracker.kt | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/SeaCreatureTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/SeaCreatureTracker.kt index 258c06c12..29ac6bf3b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/SeaCreatureTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/SeaCreatureTracker.kt @@ -4,21 +4,28 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.FishingBobberCastEvent import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.SeaCreatureFishEvent import at.hannibal2.skyhanni.features.fishing.FishingAPI import at.hannibal2.skyhanni.features.fishing.SeaCreatureManager import at.hannibal2.skyhanni.test.command.ErrorManager +import at.hannibal2.skyhanni.utils.InventoryUtils +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.LorenzUtils.addButton import at.hannibal2.skyhanni.utils.LorenzUtils.addOrPut import at.hannibal2.skyhanni.utils.LorenzUtils.sumAllValues import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.StringUtils.allLettersFirstUppercase +import at.hannibal2.skyhanni.utils.StringUtils.matches +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import at.hannibal2.skyhanni.utils.tracker.SkyHanniTracker import at.hannibal2.skyhanni.utils.tracker.TrackerData import com.google.gson.annotations.Expose import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration.Companion.seconds object SeaCreatureTracker { @@ -26,6 +33,9 @@ object SeaCreatureTracker { private val tracker = SkyHanniTracker("Sea Creature Tracker", { Data() }, { it.fishing.seaCreatureTracker }) { drawDisplay(it) } + private val trophyArmorNames by RepoPattern.pattern("fishing.trophyfishing.armor", "(BRONZE|SILVER|GOLD|DIAMOND)_HUNTER_(HELMET|CHESTPLATE|LEGGINGS|BOOTS)") + private var trophyFishingCooldown = SimpleTimeMark.farPast() + private var isTrophyFishing = false class Data : TrackerData() { override fun reset() { @@ -155,5 +165,19 @@ object SeaCreatureTracker { tracker.resetCommand(args, "shresetseacreaturetracker") } - private fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled + private fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled && !isTrophyFishing + + private fun isWearingTrophyArmor(): Boolean { + val armorInternalNames = InventoryUtils.getArmor() + return armorInternalNames.all { armorInternal -> + trophyArmorNames.matches(armorInternal?.getInternalName()?.asString().toString()) + } + } + + @SubscribeEvent + fun onTick (event: LorenzTickEvent) { + if (trophyFishingCooldown.passedSince() < 3.seconds) return + trophyFishingCooldown = SimpleTimeMark.now() + isTrophyFishing = isWearingTrophyArmor() + } } |