diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt b/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt index 0077a6e83..63cef6237 100644 --- a/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt @@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.NEUInternalName +import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull import at.hannibal2.skyhanni.utils.NumberUtil.formatLong @@ -35,13 +36,17 @@ object CollectionAPI { val collectionValue = mutableMapOf<NEUInternalName, Long>() + private val incorrectCollectionNames = mapOf( + "Mushroom" to "RED_MUSHROOM".asInternalName() + ) + @SubscribeEvent fun onProfileJoin(event: ProfileJoinEvent) { collectionValue.clear() } @SubscribeEvent - fun onTick(event: InventoryFullyOpenedEvent) { + fun onInventoryOpen(event: InventoryFullyOpenedEvent) { val inventoryName = event.inventoryName if (inventoryName.endsWith(" Collection")) { val stack = event.inventoryItems[4] ?: return @@ -49,7 +54,8 @@ object CollectionAPI { singleCounterPattern.matchMatcher(line) { val counter = group("amount").formatLong() val name = inventoryName.split(" ").dropLast(1).joinToString(" ") - collectionValue[NEUInternalName.fromItemName(name)] = counter + val internalName = incorrectCollectionNames[name] ?: NEUInternalName.fromItemName(name) + collectionValue[internalName] = counter } } CollectionUpdateEvent().postAndCatch() @@ -69,10 +75,11 @@ object CollectionAPI { name = name.split(" ").dropLast(1).joinToString(" ") } + val internalName = incorrectCollectionNames[name] ?: NEUInternalName.fromItemName(name) loop@ for (line in lore) { counterPattern.matchMatcher(line) { val counter = group("amount").formatLong() - collectionValue[NEUInternalName.fromItemName(name)] = counter + collectionValue[internalName] = counter } } } |