From 2aa92c8b1bc3d7185f8b15e8abd388cb17f68217 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 14 Dec 2023 01:40:39 +0100 Subject: Using RepoPattern in GardenLevelDisplay --- .../hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/main/java/at/hannibal2') 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 1d85443ca..d2772d837 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt @@ -13,16 +13,17 @@ import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.milliseconds class GardenLevelDisplay { private val config get() = GardenAPI.config.gardenLevels - private val expToNextLevelPattern = ".* §e(?.*)§6/.*".toPattern() - private val overflowPattern = ".*§r §6(?.*)".toPattern() - private val namePattern = "Garden Level (?.*)".toPattern() + private val expToNextLevelPattern by RepoPattern.pattern("garden.level.inventory.nextxp", ".* §e(?.*)§6/.*") + private val overflowPattern by RepoPattern.pattern("garden.level.inventory.overflow", ".*§r §6(?.*)") + private val currentLevelPattern by RepoPattern.pattern("garden.level.inventory.currentlevel", "Garden Level (?.*)") private var display = "" - private var visitorRewardPattern = " {4}§r§8\\+§r§2(?.*) §r§7Garden Experience".toPattern() + private val visitorRewardPattern by RepoPattern.pattern("garden.level.chat.increase", " {4}§r§8\\+§r§2(?.*) §r§7Garden Experience") @SubscribeEvent fun onProfileJoin(event: ProfileJoinEvent) { @@ -62,7 +63,7 @@ class GardenLevelDisplay { if (event.inventoryName != "Desk") return val item = event.inventoryItems[4]!! - val currentLevel = namePattern.matchMatcher(item.name!!.removeColor()) { + val currentLevel = currentLevelPattern.matchMatcher(item.name!!.removeColor()) { group("currentLevel").romanToDecimalIfNecessary() } ?: return var nextLevelExp = 0L -- cgit