diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-05-21 20:57:34 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-05-21 20:57:34 +0200 |
commit | 2e819d59253f91a5453d50cfaca7f998198a338b (patch) | |
tree | a63533a8cc3423c7af3a0c475ae12c3166942e3f /src | |
parent | 6a6bb74c2e08a7ac22e9cc1a12d9f800ff895288 (diff) | |
download | skyhanni-2e819d59253f91a5453d50cfaca7f998198a338b.tar.gz skyhanni-2e819d59253f91a5453d50cfaca7f998198a338b.tar.bz2 skyhanni-2e819d59253f91a5453d50cfaca7f998198a338b.zip |
Fixed Minions price profit display coin pickup time detection
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt index 623aec65a..6d32d7b1c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt @@ -4,7 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.Storage import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.ProfileStorageData -import at.hannibal2.skyhanni.events.GuiContainerEvent +import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryOpenEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.MinionOpenEvent @@ -41,7 +41,7 @@ class MinionFeatures { private var lastMinionOpened = 0L private var minionInventoryOpen = false - private var lastCoinsRecived = 0L + private var lastInventoryClosed = 0L private var lastMinionPickedUp = 0L private var coinsPerDay = "" private val minionUpgradePattern = "§aYou have upgraded your Minion to Tier (?<tier>.*)".toPattern() @@ -123,18 +123,17 @@ class MinionFeatures { } @SubscribeEvent - fun onCloseWindow(event: GuiContainerEvent.CloseWindowEvent) { + fun onInventoryClose(event: InventoryCloseEvent) { if (!minionInventoryOpen) return val minions = minions ?: return minionInventoryOpen = false lastMinionOpened = System.currentTimeMillis() + coinsPerDay = "" + lastInventoryClosed = System.currentTimeMillis() val location = lastMinion ?: return - if (System.currentTimeMillis() - lastCoinsRecived < 2_000) { - minions[location]!!.lastClicked = System.currentTimeMillis() - } if (location !in minions) { minions[location]!!.lastClicked = 0 } @@ -147,6 +146,7 @@ class MinionFeatures { @SubscribeEvent fun onTick(event: TickEvent.ClientTickEvent) { if (LorenzUtils.skyBlockIsland != IslandType.PRIVATE_ISLAND) return + if (coinsPerDay != "") return if (Minecraft.getMinecraft().currentScreen is GuiChest) { if (config.hopperProfitDisplay) { @@ -171,8 +171,6 @@ class MinionFeatures { val stack = slot.stack val line = stack.getLore().find { it.contains("Held Coins") } ?: return "" - if (coinsPerDay != "") return coinsPerDay - val duration = minions?.get(loc)?.let { val lastClicked = it.lastClicked if (lastClicked == 0L) { @@ -206,7 +204,12 @@ class MinionFeatures { val message = event.message if (message.matchRegex("§aYou received §r§6(.*) coins§r§a!")) { - lastCoinsRecived = System.currentTimeMillis() + if (System.currentTimeMillis() - lastInventoryClosed < 2_000) { + minions?.get(lastMinion)?.let { + it.lastClicked = System.currentTimeMillis() + } + } + } if (message.startsWith("§aYou picked up a minion!")) { lastMinionPickedUp = System.currentTimeMillis() |