aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils
diff options
context:
space:
mode:
authorWalker Selby <git@walkerselby.com>2023-12-09 13:36:05 -0800
committerGitHub <noreply@github.com>2023-12-09 22:36:05 +0100
commitaf7f09284caa16d7ba70c97a2c28c6a8fc1f83e6 (patch)
tree807b6333210ed518053c7f91156d0c6398f04077 /src/main/java/at/hannibal2/skyhanni/utils
parent28ecd7440c2d87628530d7b8817e14ebc66f5509 (diff)
downloadskyhanni-af7f09284caa16d7ba70c97a2c28c6a8fc1f83e6.tar.gz
skyhanni-af7f09284caa16d7ba70c97a2c28c6a8fc1f83e6.tar.bz2
skyhanni-af7f09284caa16d7ba70c97a2c28c6a8fc1f83e6.zip
Internal Change: Minion craft helper NEUInternalName (#619)
Changed MinionCraftHelper to use NeuInternalName. #619
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt39
1 files changed, 20 insertions, 19 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
index 02c8dff54..dff8a77e9 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
@@ -33,8 +33,8 @@ import java.util.regex.Pattern
object NEUItems {
val manager: NEUManager get() = NotEnoughUpdates.INSTANCE.manager
private val itemNameCache = mutableMapOf<String, NEUInternalName>() // item name -> internal name
- private val multiplierCache = mutableMapOf<String, Pair<String, Int>>()
- private val recipesCache = mutableMapOf<String, Set<NeuRecipe>>()
+ private val multiplierCache = mutableMapOf<NEUInternalName, Pair<NEUInternalName, Int>>()
+ private val recipesCache = mutableMapOf<NEUInternalName, Set<NeuRecipe>>()
private val ingredientsCache = mutableMapOf<NeuRecipe, Set<Ingredient>>()
private val enchantmentNamePattern = Pattern.compile("^(?<format>(?:§.)+)(?<name>[^§]+) (?<level>[IVXL]+)$")
var allItemsCache = mapOf<String, NEUInternalName>() // item name -> internal name
@@ -231,11 +231,6 @@ object NEUItems {
}
fun getMultiplier(internalName: NEUInternalName, tryCount: Int = 0): Pair<NEUInternalName, Int> {
- val pair = getMultiplier(internalName.asString(), tryCount)
- return Pair(pair.first.asInternalName(), pair.second)
- }
-
- fun getMultiplier(internalName: String, tryCount: Int = 0): Pair<String, Int> {
if (multiplierCache.contains(internalName)) {
return multiplierCache[internalName]!!
}
@@ -250,27 +245,27 @@ object NEUItems {
for (recipe in getRecipes(internalName)) {
if (recipe !is CraftingRecipe) continue
- val map = mutableMapOf<String, Int>()
+ val map = mutableMapOf<NEUInternalName, Int>()
for (ingredient in recipe.getCachedIngredients()) {
val count = ingredient.count.toInt()
- var internalItemId = ingredient.internalItemId
+ var internalItemId = ingredient.internalItemId.asInternalName()
// ignore cactus green
- if (internalName == "ENCHANTED_CACTUS_GREEN" && internalItemId == "INK_SACK-2") {
- internalItemId = "CACTUS"
+ if (internalName == "ENCHANTED_CACTUS_GREEN".asInternalName() && internalItemId == "INK_SACK-2".asInternalName()) {
+ internalItemId = "CACTUS".asInternalName()
}
// ignore wheat in enchanted cookie
- if (internalName == "ENCHANTED_COOKIE" && internalItemId == "WHEAT") {
+ if (internalName == "ENCHANTED_COOKIE".asInternalName() && internalItemId == "WHEAT".asInternalName()) {
continue
}
// ignore golden carrot in enchanted golden carrot
- if (internalName == "ENCHANTED_GOLDEN_CARROT" && internalItemId == "GOLDEN_CARROT") {
+ if (internalName == "ENCHANTED_GOLDEN_CARROT".asInternalName() && internalItemId == "GOLDEN_CARROT".asInternalName()) {
continue
}
// ignore rabbit hide in leather
- if (internalName == "LEATHER" && internalItemId == "RABBIT_HIDE") {
+ if (internalName == "LEATHER".asInternalName() && internalItemId == "RABBIT_HIDE".asInternalName()) {
continue
}
@@ -293,14 +288,20 @@ object NEUItems {
val result = Pair(internalName, 1)
multiplierCache[internalName] = result
return result
+
+ }
+
+ fun getMultiplier(internalName: String, tryCount: Int = 0): Pair<String, Int> {
+ val pair = getMultiplier(internalName.asInternalName(), tryCount)
+ return Pair(pair.first.asString(), pair.second)
}
- fun getRecipes(minionId: String): Set<NeuRecipe> {
- if (recipesCache.contains(minionId)) {
- return recipesCache[minionId]!!
+ fun getRecipes(internalName: NEUInternalName): Set<NeuRecipe> {
+ if (recipesCache.contains(internalName)) {
+ return recipesCache[internalName]!!
}
- val recipes = manager.getRecipesFor(minionId)
- recipesCache[minionId] = recipes
+ val recipes = manager.getRecipesFor(internalName.asString())
+ recipesCache[internalName] = recipes
return recipes
}