diff options
| author | CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> | 2024-03-22 03:44:24 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-21 17:44:24 +0100 |
| commit | ee87b805fe8a73f2e7a6d1c1562f56e440ffb374 (patch) | |
| tree | d309f54818a0b09e9a37f10046fe654a818726f7 /src/main/java/at/hannibal2/skyhanni/api | |
| parent | 841529ff4d3b81bc38a16082f8f3e892b38639f8 (diff) | |
| download | skyhanni-ee87b805fe8a73f2e7a6d1c1562f56e440ffb374.tar.gz skyhanni-ee87b805fe8a73f2e7a6d1c1562f56e440ffb374.tar.bz2 skyhanni-ee87b805fe8a73f2e7a6d1c1562f56e440ffb374.zip | |
Fix: NEUInternalName is null for item name 'Mushroom' (#1226)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/api')
| -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 } } } |
