aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-04-22 00:07:44 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-04-22 00:07:44 +0200
commitb45ba72dc4f6a8904a37d4978bf7823b4ccda424 (patch)
tree44372308596e54de55a3d7ade1d612fa15bf58d1
parent785e26f6d9ddd9803aa714e607d5c2baf622a7f2 (diff)
downloadskyhanni-b45ba72dc4f6a8904a37d4978bf7823b4ccda424.tar.gz
skyhanni-b45ba72dc4f6a8904a37d4978bf7823b4ccda424.tar.bz2
skyhanni-b45ba72dc4f6a8904a37d4978bf7823b4ccda424.zip
fixed errors by using regex over split
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt
index 25a899942..87e279b2d 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt
@@ -20,6 +20,7 @@ class ItemDisplayOverlayFeatures {
private val wishingCompassPattern = "§7Remaining Uses: §e(.*)§8/§e3".toPattern()
private val rangerBootsSpeedCapPattern = "§7Current Speed Cap: §a(.*)".toPattern()
+ private val petLevelPattern = "\\[Lvl (?<level>.*)] (?:.*)".toPattern()
@SubscribeEvent
fun onRenderItemTip(event: RenderItemTipEvent) {
@@ -69,9 +70,12 @@ class ItemDisplayOverlayFeatures {
val chestName = InventoryUtils.openInventoryName()
if (!chestName.endsWith("Sea Creature Guide")) {
if (ItemUtils.isPet(itemName)) {
- val level = itemName.between("Lvl ", "] ").toInt()
- if (level != ItemUtils.maxPetLevel(itemName)) {
- return "$level"
+ val matcher = petLevelPattern.matcher(itemName)
+ if (matcher.matches()) {
+ val level = matcher.group("level").toInt()
+ if (level != ItemUtils.maxPetLevel(itemName)) {
+ return "$level"
+ }
}
}
}