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 | |
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')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/ItemNameResolver.kt | 13 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt | 17 |
2 files changed, 22 insertions, 8 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() } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt index 0324efcbb..a5ffc6e14 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt @@ -14,7 +14,6 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.NumberUtil.isInt import at.hannibal2.skyhanni.utils.PrimitiveItemStack.Companion.makePrimitiveStack -import at.hannibal2.skyhanni.utils.StringUtils.removeColor import com.google.gson.JsonObject import com.google.gson.JsonPrimitive import com.google.gson.TypeAdapter @@ -123,10 +122,20 @@ object NEUItems { allInternalNames.clear() val map = mutableMapOf<String, NEUInternalName>() for (rawInternalName in allNeuRepoItems().keys) { - val name = manager.createItem(rawInternalName).displayName.removeColor().lowercase() + var name = manager.createItem(rawInternalName).displayName.lowercase() val internalName = rawInternalName.asInternalName() - val storedName = name.removePrefix("[lvl 1➡100] ") - map[storedName] = internalName + + // TODO remove one of them once neu is consistent + name = name.removePrefix("§f§f§7[lvl 1➡100] ") + name = name.removePrefix("§7[lvl 1➡100] ") + + if (name.contains("[lvl 1➡100]")) { + if (LorenzUtils.isInDevEnvironment()) { + error("wrong name: '$name'") + } + println("wrong name: '$name'") + } + map[name] = internalName allInternalNames.add(internalName) } return map |