diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-11-02 20:41:55 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-11-02 20:41:55 +0100 |
commit | ec2d189ede2487a98943339fa7816a0e948e7a90 (patch) | |
tree | e7b62b882ffcf43a9d89a807d42d9cecff706c2e /src/main/java/at/hannibal2/skyhanni | |
parent | af3e264dbeba9ab4b9ba4bae1334fa31232f7d78 (diff) | |
download | skyhanni-ec2d189ede2487a98943339fa7816a0e948e7a90.tar.gz skyhanni-ec2d189ede2487a98943339fa7816a0e948e7a90.tar.bz2 skyhanni-ec2d189ede2487a98943339fa7816a0e948e7a90.zip |
Auto reset on year change, also added /shkingfix support
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt | 5 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt | 54 |
2 files changed, 40 insertions, 19 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt index 1e32ff718..82318656a 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -24,6 +24,7 @@ import at.hannibal2.skyhanni.features.garden.farming.FarmingWeightDisplay import at.hannibal2.skyhanni.features.garden.farming.GardenStartLocation import at.hannibal2.skyhanni.features.garden.fortuneguide.CaptureFarmingGear import at.hannibal2.skyhanni.features.garden.fortuneguide.FFGuideGUI +import at.hannibal2.skyhanni.features.mining.KingTalismanHelper import at.hannibal2.skyhanni.features.minion.MinionFeatures import at.hannibal2.skyhanni.features.misc.CollectionTracker import at.hannibal2.skyhanni.features.misc.LockMouseLook @@ -218,6 +219,10 @@ object Commands { "shrepostatus", "Shows the status of all the mods constants" ) { SkyHanniMod.repo.displayRepoStatus(false) } + registerCommand( + "shkingfix", + "Reseting the local King Talisman Helper offset." + ) { KingTalismanHelper.kingFix() } } private fun developersDebugFeatures() { 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 33d5b174c..e9fc47dca 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt @@ -23,7 +23,23 @@ import java.util.Collections class KingTalismanHelper { private val config get() = SkyHanniMod.feature.mining.kingTalisman - private var currentOffset: Int? = null + + companion object { + private var currentOffset: Int? = null + private var skyblockYear = 0 + + private fun getCurrentOffset(): Int? { + if (SkyBlockTime.now().year != skyblockYear) { + return null + } + return currentOffset + } + + fun kingFix() { + currentOffset = null + LorenzUtils.chat("§e[SkyHanni] Reset internal offset of King Talisman Helper.") + } + } private val kingLocation = LorenzVec(129.6, 196.5, 194.1) private val kingCircles = listOf( @@ -37,7 +53,7 @@ class KingTalismanHelper { ) private var allKingsDisplay = emptyList<String>() - private var farDisplay = "Visit the king to sync up." + private var farDisplay = "" private var display = emptyList<String>() private fun isNearby() = IslandType.DWARVEN_MINES.isInIsland() && LorenzUtils.skyBlockArea == "Royal Palace" && @@ -46,21 +62,22 @@ class KingTalismanHelper { @SubscribeEvent fun onTick(event: LorenzTickEvent) { if (!event.isMod(20)) return + if (!isEnabled()) return + val profileSpecific = ProfileStorageData.profileSpecific ?: return - if (!isEnabled()) { - display = emptyList() - return - } val nearby = isNearby() - if (nearby) { - if (currentOffset == null) { - checkOffset() - } + if (nearby && getCurrentOffset() == null) { + checkOffset() } - if (currentOffset == null) return + val kingsTalkedTo = profileSpecific.mining.kingsTalkedTo + if (getCurrentOffset() == null) { + val allKings = kingsTalkedTo.size == kingCircles.size + display = if (allKings) emptyList() else listOf("§cVisit the king to sync up.") + return + } - update() + update(kingsTalkedTo) display = if (nearby) allKingsDisplay else Collections.singletonList(farDisplay) } @@ -74,6 +91,7 @@ class KingTalismanHelper { val currentId = kingCircles.indexOf(getCurrentKing()) val foundId = kingCircles.indexOf(foundKing) currentOffset = currentId - foundId + skyblockYear = SkyBlockTime.now().year } fun isEnabled() = config.enabled && LorenzUtils.inSkyBlock @@ -83,7 +101,7 @@ class KingTalismanHelper { fun onInventoryOpen(event: InventoryFullyOpenedEvent) { if (event.inventoryName != "Commissions") return if (!isEnabled()) return - if (currentOffset == null) return + if (getCurrentOffset() == null) return if (!isNearby()) return val profileSpecific = ProfileStorageData.profileSpecific ?: return @@ -92,14 +110,12 @@ class KingTalismanHelper { if (currentKing !in kingsTalkedTo) { LorenzUtils.debug("Found new king!") kingsTalkedTo.add(currentKing) - update() + update(kingsTalkedTo) display = allKingsDisplay } } - private fun update() { - val profileSpecific = ProfileStorageData.profileSpecific ?: return - val kingsTalkedTo = profileSpecific.mining.kingsTalkedTo + private fun update(kingsTalkedTo: MutableList<String>) { if (kingsTalkedTo.size == kingCircles.size) { allKingsDisplay = Collections.singletonList("§eAll Kings found.") farDisplay = "" @@ -147,7 +163,7 @@ class KingTalismanHelper { } private fun getKingTimes(): MutableMap<String, Long> { - val currentOffset = currentOffset ?: 0 + val currentOffset = getCurrentOffset() ?: 0 val oneSbDay = 1000 * 60 * 20 val oneCircleTime = oneSbDay * kingCircles.size val kingTime = mutableMapOf<String, Long>() @@ -169,7 +185,7 @@ class KingTalismanHelper { @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { - if (!config.enabled) return + if (!isEnabled()) return config.position.renderStrings(display, posLabel = "King Talisman Helper") } |