diff options
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt | 27 |
1 files 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(?<nextLevelExp>.*)§6/.*" ) + private val gardenItemNamePattern by patternGroup.pattern( + "inventory.name", + "Garden (?:Desk|Level (?<currentLevel>.*))" + ) private val overflowPattern by patternGroup.pattern( "inventory.overflow", ".*§r §6(?<overflow>.*)" ) - private val currentLevelPattern by patternGroup.pattern( - "inventory.currentlevel", - "Garden Level (?<currentLevel>.*)" + private val gardenLevelPattern by patternGroup.pattern( + "inventory.levelprogress", + "§7Progress to Level (?<currentLevel>[^:]*).*" ) 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() } |