diff options
author | CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> | 2024-04-05 10:56:09 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-05 10:56:09 +1100 |
commit | 940b961edc0bea93fafa99764454196b0d47e42b (patch) | |
tree | c26528128271c5a008cc55d8387231862efec622 /src/main/java/at/hannibal2/skyhanni/data | |
parent | d991a496edc2181806e56dd5aea07161349a4e87 (diff) | |
download | skyhanni-940b961edc0bea93fafa99764454196b0d47e42b.tar.gz skyhanni-940b961edc0bea93fafa99764454196b0d47e42b.tar.bz2 skyhanni-940b961edc0bea93fafa99764454196b0d47e42b.zip |
Backend: Use only one inventory close event (#1184)
* use only one inventory close event
* fix InventoryCloseEvent not getting called when closing player inventory, not fully opened inventories, and sometimes leaving inventories by opening other mod menus
* used event in minion collection, and renamed functions
---------
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data')
3 files changed, 7 insertions, 9 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ItemAddManager.kt b/src/main/java/at/hannibal2/skyhanni/data/ItemAddManager.kt index 601fafb12..498d87d10 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ItemAddManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ItemAddManager.kt @@ -1,6 +1,6 @@ package at.hannibal2.skyhanni.data -import at.hannibal2.skyhanni.events.GuiContainerEvent +import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryOpenEvent import at.hannibal2.skyhanni.events.ItemAddEvent import at.hannibal2.skyhanni.events.LorenzChatEvent @@ -42,7 +42,7 @@ class ItemAddManager { } @SubscribeEvent - fun onInventoryClose(event: GuiContainerEvent.CloseWindowEvent) { + fun onInventoryClose(event: InventoryCloseEvent) { if (inSackInventory) { inSackInventory = false lastSackInventoryLeave = SimpleTimeMark.now() diff --git a/src/main/java/at/hannibal2/skyhanni/data/OtherInventoryData.kt b/src/main/java/at/hannibal2/skyhanni/data/OtherInventoryData.kt index 72395b4fc..cfe08927e 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/OtherInventoryData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/OtherInventoryData.kt @@ -24,10 +24,8 @@ object OtherInventoryData { } fun close(reopenSameName: Boolean = false) { - currentInventory?.let { - InventoryCloseEvent(it, reopenSameName).postAndCatch() - currentInventory = null - } + InventoryCloseEvent(reopenSameName).postAndCatch() + currentInventory = null } @SubscribeEvent @@ -50,8 +48,7 @@ object OtherInventoryData { val windowId = packet.windowId val title = packet.windowTitle.unformattedText val slotCount = packet.slotCount - val reopenSameName = title == currentInventory?.title - close(reopenSameName) + close(reopenSameName = title == currentInventory?.title) currentInventory = Inventory(windowId, title, slotCount) acceptItems = true diff --git a/src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt b/src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt index edc07287a..759254ff6 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.events.GuiContainerEvent +import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent @@ -106,7 +107,7 @@ class OwnInventoryData { } @SubscribeEvent - fun onInventoryClose(event: GuiContainerEvent.CloseWindowEvent) { + fun onInventoryClose(event: InventoryCloseEvent) { val item = Minecraft.getMinecraft().thePlayer.inventory.itemStack ?: return val internalNameOrNull = item.getInternalNameOrNull() ?: return ignoreItem(500.milliseconds) { it == internalNameOrNull } |