From c98bbe34efab04cf46dde6a573b57275a69c5722 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 9 Nov 2023 21:47:06 +0100 Subject: Added support for slayer tracker items for loot from area mini-bosses. Fixed a bug where some items were counted twice. --- .../at/hannibal2/skyhanni/api/CollectionAPI.kt | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/api') diff --git a/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt b/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt index 2476cbe73..29ce97471 100644 --- a/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.api import at.hannibal2.skyhanni.events.CollectionUpdateEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent +import at.hannibal2.skyhanni.events.entity.ItemAddInInventoryEvent import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils @@ -66,6 +67,17 @@ class CollectionAPI { } } + @SubscribeEvent + fun onItemAdd(event: ItemAddInInventoryEvent) { + // TODO add support for replenish (higher collection than actual items in inv) + val internalName = event.internalName + if (internalName.getItemStackOrNull() == null) { + LorenzUtils.debug("CollectionAPI.addFromInventory: item is null for '$internalName'") + return + } + collectionValue.addOrPut(internalName, event.amount.toLong()) + } + companion object { // TODO USE SH-REPO val collectionValue = mutableMapOf() @@ -74,14 +86,5 @@ class CollectionAPI { fun isCollectionTier0(lore: List) = lore.map { collectionTier0Pattern.matcher(it) }.any { it.matches() } fun getCollectionCounter(internalName: NEUInternalName): Long? = collectionValue[internalName] - - // TODO add support for replenish (higher collection than actual items in inv) - fun addFromInventory(internalName: NEUInternalName, amount: Int) { - if (internalName.getItemStackOrNull() == null) { - LorenzUtils.debug("CollectionAPI.addFromInventory: item is null for '$internalName'") - return - } - collectionValue.addOrPut(internalName, amount.toLong()) - } } -} \ No newline at end of file +} -- cgit