aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-04-16 19:51:53 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-04-16 19:51:53 +0200
commitd82f1a825da599650ee2b6aab84a97e90abf4745 (patch)
treed12df6794deb7aedea8ba620dc611e7423012fca /src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
parentf01195b5cf091dedbddd5e76b3a7e273b89fe2db (diff)
downloadskyhanni-d82f1a825da599650ee2b6aab84a97e90abf4745.tar.gz
skyhanni-d82f1a825da599650ee2b6aab84a97e90abf4745.tar.bz2
skyhanni-d82f1a825da599650ee2b6aab84a97e90abf4745.zip
Fixed bazaar detection with turbo books again
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
index 5a2f1dc3a..71bcc2f09 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.utils
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
+import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal
import io.github.moulberry.notenoughupdates.NEUManager
import io.github.moulberry.notenoughupdates.NotEnoughUpdates
import io.github.moulberry.notenoughupdates.recipes.CraftingRecipe
@@ -19,6 +20,7 @@ object NEUItems {
private val itemNameCache = mutableMapOf<String, String>() // item name -> internal name
private val multiplierCache = mutableMapOf<String, Pair<String, Int>>()
private val recipesCache = mutableMapOf<String, Set<NeuRecipe>>()
+ private val turboBookPattern = "§fTurbo-(?<name>.*) (?<level>.)".toPattern()
fun getInternalName(itemName: String): String {
return getInternalNameOrNull(itemName) ?: throw Error("getInternalName is null for '$itemName'")
@@ -28,7 +30,16 @@ object NEUItems {
if (itemNameCache.containsKey(itemName)) {
return itemNameCache[itemName]!!
}
- var internalName = ItemResolutionQuery.findInternalNameByDisplayName(itemName, false) ?: return null
+
+ val matcher = turboBookPattern.matcher(itemName)
+ var internalName = if (matcher.matches()) {
+ val type = matcher.group("name")
+ val level = matcher.group("level").romanToDecimal()
+ val name = turboCheck(type).uppercase()
+ "TURBO_$name;$level"
+ } else {
+ ItemResolutionQuery.findInternalNameByDisplayName(itemName, false) ?: return null
+ }
// This fixes a NEU bug with §9Hay Bale (cosmetic item)
// TODO remove workaround when this is fixed in neu
@@ -40,6 +51,12 @@ object NEUItems {
return internalName
}
+ private fun turboCheck(text: String): String {
+ if (text == "Cocoa") return "Coco"
+ if (text == "Cacti") return "Cactus"
+ return text
+ }
+
fun getInternalName(itemStack: ItemStack): String {
return ItemResolutionQuery(manager)
.withCurrentGuiContext()