aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/api')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt23
1 files changed, 13 insertions, 10 deletions
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<NEUInternalName, Long>()
@@ -74,14 +86,5 @@ class CollectionAPI {
fun isCollectionTier0(lore: List<String>) = 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
+}