From 2fe944ca32cd080945f52afd80b33f2ed8e7ef43 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Thu, 2 May 2024 09:27:50 +0200 Subject: Backend: Pet rarity support (#1623) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../java/at/hannibal2/skyhanni/utils/ItemNameResolver.kt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/utils/ItemNameResolver.kt') 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() } } -- cgit