diff options
author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-08-23 09:46:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-23 09:46:57 +0200 |
commit | b2a86892cc7078aa00ea68296919bfb496bb3451 (patch) | |
tree | 1a076322e7a16d256e9847d7c12353c419f4c67d /src/main/java/at/hannibal2/skyhanni/data | |
parent | 57c1220bc9084b766c554c00636cc8ca89832ee0 (diff) | |
download | skyhanni-b2a86892cc7078aa00ea68296919bfb496bb3451.tar.gz skyhanni-b2a86892cc7078aa00ea68296919bfb496bb3451.tar.bz2 skyhanni-b2a86892cc7078aa00ea68296919bfb496bb3451.zip |
Fix: AH Item movements item trackers (#2380)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt b/src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt index 0ce4309c7..0b4abf425 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt @@ -15,7 +15,9 @@ import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut import at.hannibal2.skyhanni.utils.DelayedRun import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull +import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.itemName +import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher @@ -37,7 +39,7 @@ object OwnInventoryData { private var dirty = false private val sackToInventoryChatPattern by RepoPattern.pattern( "data.owninventory.chat.movedsacktoinventory", - "§aMoved §r§e\\d* (?<name>.*)§r§a from your Sacks to your inventory." + "§aMoved §r§e\\d* (?<name>.*)§r§a from your Sacks to your inventory.", ) @HandleEvent(priority = HandleEvent.LOW, receiveCancelled = true, onlyOnSkyblock = true) @@ -117,6 +119,46 @@ object OwnInventoryData { @SubscribeEvent fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) { ignoreItem(500.milliseconds) { true } + + val itemName = event.item?.name ?: return + checkAHMovements(itemName) + } + + private fun checkAHMovements(itemName: String) { + val inventoryName = InventoryUtils.openInventoryName() + + // cancel own auction + if (inventoryName.let { it == "BIN Auction View" || it == "Auction View" }) { + if (itemName == "§cCancel Auction") { + val item = InventoryUtils.getItemAtSlotIndex(13) + val internalName = item?.getInternalNameOrNull() ?: return + OwnInventoryData.ignoreItem(5.seconds, { it == internalName }) + } + } + + // bought item from bin ah + if (inventoryName == "Confirm Purchase" && itemName == "§aConfirm") { + val item = InventoryUtils.getItemAtSlotIndex(13) + val internalName = item?.getInternalNameOrNull() ?: return + OwnInventoryData.ignoreItem(5.seconds, { it == internalName }) + } + + // bought item from normal ah + if (inventoryName == "Auction View" && itemName == "§6Collect Auction") { + val item = InventoryUtils.getItemAtSlotIndex(13) + val internalName = item?.getInternalNameOrNull() ?: return + OwnInventoryData.ignoreItem(5.seconds, { it == internalName }) + } + + // collected all items in "own bins" + if (inventoryName == "Your Bids" && itemName == "§aClaim All") { + for (stack in InventoryUtils.getItemsInOpenChest().map { it.stack }) { + if (stack.getLore().any { it == "§7Status: §aSold!" || it == "7Status: §aEnded!" }) { + val internalName = stack.getInternalNameOrNull() ?: return + OwnInventoryData.ignoreItem(5.seconds, { it == internalName }) + } + } + } } @SubscribeEvent @@ -127,7 +169,6 @@ object OwnInventoryData { } } - // TODO add ah movements fun ignoreItem(duration: Duration, condition: (NEUInternalName) -> Boolean) { ignoredItemsUntil.add(IgnoredItem(condition, SimpleTimeMark.now() + duration)) } |