diff options
Diffstat (limited to 'src/main/java')
-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() |