aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features
diff options
context:
space:
mode:
authorEmpa <42304516+ItsEmpa@users.noreply.github.com>2024-03-17 19:23:12 +0100
committerGitHub <noreply@github.com>2024-03-17 19:23:12 +0100
commitbf462fa2aa335794b86df58ffcfa6dd8ea4f04f2 (patch)
treec78d5efb954c5aa37659566566f4bba9abf47c73 /src/main/java/at/hannibal2/skyhanni/features
parent6e32cd257e2ff2274881df3d6db50d0e851dff0c (diff)
downloadskyhanni-bf462fa2aa335794b86df58ffcfa6dd8ea4f04f2.tar.gz
skyhanni-bf462fa2aa335794b86df58ffcfa6dd8ea4f04f2.tar.bz2
skyhanni-bf462fa2aa335794b86df58ffcfa6dd8ea4f04f2.zip
Improvement: Garden level from Skyblock menu (#1164)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt27
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()
}