aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/ItemNameResolver.kt1
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt9
2 files changed, 10 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemNameResolver.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemNameResolver.kt
index d17f579ed..baf9ee8ea 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/ItemNameResolver.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemNameResolver.kt
@@ -74,6 +74,7 @@ object ItemNameResolver {
if (NEUItems.allItemsCache.isEmpty()) {
NEUItems.allItemsCache = NEUItems.readAllNeuItems()
}
+
NEUItems.allItemsCache[lowercase]?.let {
itemNameCache[lowercase] = it
return it
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
index 69f1e4fc3..1ca6e2a70 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
@@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.utils
import at.hannibal2.skyhanni.config.ConfigManager
import at.hannibal2.skyhanni.data.jsonobjects.repo.MultiFilterJson
+import at.hannibal2.skyhanni.events.NeuRepositoryReloadEvent
import at.hannibal2.skyhanni.events.RepositoryReloadEvent
import at.hannibal2.skyhanni.features.bazaar.BazaarDataHolder
import at.hannibal2.skyhanni.test.command.ErrorManager
@@ -40,6 +41,7 @@ object NEUItems {
private val ingredientsCache = mutableMapOf<NeuRecipe, Set<Ingredient>>()
var allItemsCache = mapOf<String, NEUInternalName>() // item name -> internal name
+ val allInternalNames = mutableListOf<NEUInternalName>()
val ignoreItemsFilter = MultiFilter()
private val fallbackItem by lazy {
@@ -56,15 +58,22 @@ object NEUItems {
ignoreItemsFilter.load(ignoredItems)
}
+ @SubscribeEvent
+ fun onNeuRepoReload(event: NeuRepositoryReloadEvent) {
+ allItemsCache = readAllNeuItems()
+ }
+
@Deprecated("Use NEUInternalName rather than String", ReplaceWith("getInternalNameFromItemName()"))
fun getRawInternalName(itemName: String): String = NEUInternalName.fromItemName(itemName).asString()
fun readAllNeuItems(): Map<String, NEUInternalName> {
+ allInternalNames.clear()
val map = mutableMapOf<String, NEUInternalName>()
for (rawInternalName in allNeuRepoItems().keys) {
val name = manager.createItem(rawInternalName).displayName.removeColor().lowercase()
val internalName = rawInternalName.asInternalName()
map[name] = internalName
+ allInternalNames.add(internalName)
}
return map
}