diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt | 11 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt | 12 |
2 files changed, 20 insertions, 3 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt index c22a72971..919b88969 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt @@ -137,9 +137,14 @@ object ItemUtils { fun isSkyBlockMenuItem(stack: ItemStack?): Boolean = stack?.getInternalName() == "SKYBLOCK_MENU" - private val pattern = Pattern.compile("(?<name>(?:[\\w-]+ ?)+)(?:§8x(?<amount>\\d+))?") + private val pattern = Pattern.compile("(?<name>(?:['\\w-]+ ?)+)(?:§8x(?<amount>\\d+))?") + + private val itemAmountCache = mutableMapOf<String, Pair<String, Int>>() fun readItemAmount(input: String): Pair<String?, Int> { + if (itemAmountCache.containsKey(input)) { + return itemAmountCache[input]!! + } var string = input.trim() val color = string.substring(0, 2) string = string.substring(2) @@ -148,6 +153,8 @@ object ItemUtils { val itemName = color + matcher.group("name").trim() val amount = matcher.group("amount")?.replace(",", "")?.toInt() ?: 1 - return Pair(itemName, amount) + val pair = Pair(itemName, amount) + itemAmountCache[input] = pair + return pair } }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt index 0f7a15618..4e285e112 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt @@ -12,9 +12,19 @@ import net.minecraft.item.ItemStack object NEUItems { val manager: NEUManager get() = NotEnoughUpdates.INSTANCE.manager private val itemCache = mutableMapOf<String, ItemStack>() + private val itemNameCache = mutableMapOf<String, String>() // item name -> internal name fun getInternalName(itemName: String): String { - return ItemResolutionQuery.findInternalNameByDisplayName(itemName, false) + if (itemNameCache.containsKey(itemName)) { + return itemNameCache[itemName]!! + } + // We love hypixel naming moments + val name = if (itemName.contains("Jack o' Lantern")) { + itemName.replace("Jack o' Lantern", "Jack o'Lantern") + } else itemName + val internalName = ItemResolutionQuery.findInternalNameByDisplayName(name, false) + itemNameCache[itemName] = internalName + return internalName } fun getInternalName(itemStack: ItemStack): String { |