aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/ItemNameResolver.kt13
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt17
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