aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
index e44cccd9a..6b52d1eb2 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
@@ -26,11 +26,6 @@ import kotlin.time.Duration.Companion.seconds
object ItemUtils {
- // TODO USE SH-REPO
- private val patternInFront = "(?: *§8(\\+§\\w)?(?<amount>[\\d.km,]+)(x )?)?(?<name>.*)".toPattern()
- private val patternBehind = "(?<name>(?:['\\w-]+ ?)+)(?:§8x(?<amount>[\\d,]+))?".toPattern()
- private val petLevelPattern = "\\[Lvl (.*)] (.*)".toPattern()
-
private val ignoredPetStrings = listOf(
"Archer",
"Berserk",
@@ -66,7 +61,7 @@ object ItemUtils {
fun isRecombobulated(stack: ItemStack) = stack.isRecombobulated()
- fun isPet(name: String): Boolean = petLevelPattern.matches(name) && !ignoredPetStrings.any { name.contains(it) }
+ fun isPet(name: String): Boolean = UtilsPatterns.petLevelPattern.matches(name) && !ignoredPetStrings.any { name.contains(it) }
fun maxPetLevel(name: String) = if (name.contains("Golden Dragon")) 200 else 100
@@ -323,18 +318,17 @@ object ItemUtils {
return itemAmountCache[input]!!
}
- var matcher = patternInFront.matcher(input)
- if (matcher.matches()) {
- val itemName = matcher.group("name")
+ UtilsPatterns.readAmountBeforePattern.matchMatcher(input) {
+ val itemName = group("name")
if (!itemName.contains("§8x")) {
- return makePair(input, itemName.trim(), matcher)
+ return makePair(input, itemName.trim(), this)
}
}
var string = input.trim()
val color = string.substring(0, 2)
string = string.substring(2)
- matcher = patternBehind.matcher(string)
+ val matcher = UtilsPatterns.readAmountAfterPattern.matcher(string)
if (!matcher.matches()) {
println("")
println("input: '$input'")