diff options
author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-05-02 09:27:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-02 09:27:50 +0200 |
commit | 2fe944ca32cd080945f52afd80b33f2ed8e7ef43 (patch) | |
tree | bbecb43307705f2d736676342595b9b8ffeafd24 /src/main/java/at/hannibal2/skyhanni/utils/ItemNameResolver.kt | |
parent | 9b145a1c80bf2edfb378c7613985f58cd6ec2e92 (diff) | |
download | skyhanni-2fe944ca32cd080945f52afd80b33f2ed8e7ef43.tar.gz skyhanni-2fe944ca32cd080945f52afd80b33f2ed8e7ef43.tar.bz2 skyhanni-2fe944ca32cd080945f52afd80b33f2ed8e7ef43.zip |
Backend: Pet rarity support (#1623)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/ItemNameResolver.kt')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/ItemNameResolver.kt | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemNameResolver.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemNameResolver.kt index 569729b8d..d4aa86b50 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ItemNameResolver.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemNameResolver.kt @@ -16,6 +16,10 @@ object ItemNameResolver { return it } + getInternalNameOrNullIgnoreCase(itemName)?.let { + return itemNameCache.getOrPut(lowercase) { it } + } + if (itemName == "§cmissing repo item") { return itemNameCache.getOrPut(lowercase) { NEUInternalName.MISSING_ITEM } } @@ -56,8 +60,6 @@ object ItemNameResolver { // TODO remove workaround when this is fixed in neu val rawInternalName = if (it == "HAY_BALE") "HAY_BLOCK" else it rawInternalName.asInternalName() - } ?: run { - getInternalNameOrNullIgnoreCase(itemName) } ?: return null } } @@ -95,7 +97,7 @@ object ItemNameResolver { } private fun getInternalNameOrNullIgnoreCase(itemName: String): NEUInternalName? { - val lowercase = itemName.removeColor().lowercase() + val lowercase = itemName.lowercase() itemNameCache[lowercase]?.let { return it } @@ -104,11 +106,14 @@ object ItemNameResolver { NEUItems.allItemsCache = NEUItems.readAllNeuItems() } + // supports colored names, rarities NEUItems.allItemsCache[lowercase]?.let { itemNameCache[lowercase] = it return it } - return null + // if nothing got found with colors, try without colors + val removeColor = lowercase.removeColor() + return NEUItems.allItemsCache.filter { it.key.removeColor() == removeColor }.values.firstOrNull() } } |