summaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-03-31 20:08:47 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-03-31 20:08:47 +0200
commit58eccf5c7bf37c6279e15cd9e107b1fafd6e4509 (patch)
treeef98c7cfcc0ef2032a635393eda2a3c0a39a87be /src/main/java/at/hannibal2/skyhanni/utils
parent33c7a5c0a13e98af7895aeb7eaf3109a3c841a5f (diff)
downloadskyhanni-58eccf5c7bf37c6279e15cd9e107b1fafd6e4509.tar.gz
skyhanni-58eccf5c7bf37c6279e15cd9e107b1fafd6e4509.tar.bz2
skyhanni-58eccf5c7bf37c6279e15cd9e107b1fafd6e4509.zip
Added Composter Upgrade Price - Show the price for the composter upgrade in the lore
Added Highlight Upgrade - Highlight Upgrades that can be bought right now. Added Number Composter Upgrades - Show the number of upgrades in the composter upgrades inventory.
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt15
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt1
2 files changed, 14 insertions, 2 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
index bbd420743..cf0192ca4 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
@@ -137,7 +137,8 @@ object ItemUtils {
fun isSkyBlockMenuItem(stack: ItemStack?): Boolean = stack?.getInternalName() == "SKYBLOCK_MENU"
- private val pattern = Pattern.compile("(?<name>(?:['\\w-]+ ?)+)(?:§8x(?<amount>[\\d,]+))?")
+ private val patternInFront = Pattern.compile("(?: *§8(?<amount>[\\d,]+)x )?(?<name>.*)")
+ private val patternBehind = Pattern.compile("(?<name>(?:['\\w-]+ ?)+)(?:§8x(?<amount>[\\d,]+))?")
private val itemAmountCache = mutableMapOf<String, Pair<String, Int>>()
@@ -145,10 +146,20 @@ object ItemUtils {
if (itemAmountCache.containsKey(input)) {
return itemAmountCache[input]!!
}
+
+ var matcher = patternInFront.matcher(input)
+ if (matcher.matches()) {
+ val itemName = matcher.group("name")
+ val amount = matcher.group("amount")?.replace(",", "")?.toInt() ?: 1
+ val pair = Pair(itemName, amount)
+ itemAmountCache[input] = pair
+ return pair
+ }
+
var string = input.trim()
val color = string.substring(0, 2)
string = string.substring(2)
- val matcher = pattern.matcher(string)
+ matcher = patternBehind.matcher(string)
if (!matcher.matches()) return Pair(null, 0)
val itemName = color + matcher.group("name").trim()
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
index 8e9b9de9e..921229e05 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
@@ -62,6 +62,7 @@ object LorenzUtils {
}
fun error(message: String) {
+ println("error: '$message'")
internalChat("§c$message")
}