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 | |
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')
3 files changed, 17 insertions, 5 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 } } } diff --git a/src/main/java/at/hannibal2/skyhanni/test/DebugCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/DebugCommand.kt index 4a379fed6..699239c9e 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/DebugCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/DebugCommand.kt @@ -28,7 +28,7 @@ object DebugCommand { if (search.equalsIgnoreColor("all")) { "search for everything:" } else "search '$search':" - } else "search is not specified, show only interesting stuff:" + } else "no search specified, only showing interesting stuff:" ) val event = DebugDataCollectEvent(list, search) diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUInternalName.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUInternalName.kt index 368877079..ab71a7e2e 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NEUInternalName.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUInternalName.kt @@ -1,5 +1,7 @@ package at.hannibal2.skyhanni.utils +import at.hannibal2.skyhanni.test.command.ErrorManager + class NEUInternalName private constructor(private val internalName: String) { companion object { @@ -20,7 +22,10 @@ class NEUInternalName private constructor(private val internalName: String) { fun fromItemNameOrNull(itemName: String): NEUInternalName? = ItemNameResolver.getInternalNameOrNull(itemName) fun fromItemName(itemName: String): NEUInternalName = - fromItemNameOrNull(itemName) ?: throw Error("NEUInternalName is null for item name '$itemName'") + fromItemNameOrNull(itemName) ?: ErrorManager.skyHanniError( + "NEUInternalName is null for item name: '$itemName'", + "inventoryName" to InventoryUtils.openInventoryName() + ) } fun asString() = internalName |