From bf462fa2aa335794b86df58ffcfa6dd8ea4f04f2 Mon Sep 17 00:00:00 2001 From: Empa <42304516+ItsEmpa@users.noreply.github.com> Date: Sun, 17 Mar 2024 19:23:12 +0100 Subject: Improvement: Garden level from Skyblock menu (#1164) --- .../skyhanni/features/garden/GardenLevelDisplay.kt | 27 ++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt index 766bdd55d..40df08a57 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt @@ -28,13 +28,17 @@ class GardenLevelDisplay { "inventory.nextxp", ".* §e(?.*)§6/.*" ) + private val gardenItemNamePattern by patternGroup.pattern( + "inventory.name", + "Garden (?:Desk|Level (?.*))" + ) private val overflowPattern by patternGroup.pattern( "inventory.overflow", ".*§r §6(?.*)" ) - private val currentLevelPattern by patternGroup.pattern( - "inventory.currentlevel", - "Garden Level (?.*)" + private val gardenLevelPattern by patternGroup.pattern( + "inventory.levelprogress", + "§7Progress to Level (?[^:]*).*" ) private val visitorRewardPattern by patternGroup.pattern( "chat.increase", @@ -78,14 +82,19 @@ class GardenLevelDisplay { @SubscribeEvent fun onInventoryOpen(event: InventoryFullyOpenedEvent) { if (!GardenAPI.inGarden()) return - if (event.inventoryName != "Desk") return - val item = event.inventoryItems[4]!! - - val currentLevel = currentLevelPattern.matchMatcher(item.name.removeColor()) { - group("currentLevel").romanToDecimalIfNecessary() - } ?: return + val item = when (event.inventoryName) { + "Desk" -> event.inventoryItems[4] ?: return + "SkyBlock Menu" -> event.inventoryItems[10] ?: return + else -> return + } + gardenItemNamePattern.matchMatcher(item.name.removeColor()) {} ?: return var nextLevelExp = 0L + var currentLevel = 0 for (line in item.getLore()) { + gardenLevelPattern.matchMatcher(line) { + currentLevel = group("currentLevel").romanToDecimalIfNecessary() - 1 + } + if (line == "§7§8Max level reached!") currentLevel = 15 expToNextLevelPattern.matchMatcher(line) { nextLevelExp = group("nextLevelExp").formatLong() } -- cgit