diff options
author | CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> | 2024-02-16 21:21:43 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-16 11:21:43 +0100 |
commit | f91973d60948d449cc45a4add901e6fe43aebd62 (patch) | |
tree | 4c8c77ec4a9585a821651a034ebe5bed3308a6af /src/main/java/at/hannibal2/skyhanni/features/slayer | |
parent | 26fe548fa9a5cfe29b130a0a5585278df3429ee9 (diff) | |
download | skyhanni-f91973d60948d449cc45a4add901e6fe43aebd62.tar.gz skyhanni-f91973d60948d449cc45a4add901e6fe43aebd62.tar.bz2 skyhanni-f91973d60948d449cc45a4add901e6fe43aebd62.zip |
Moved many regex patterns in the repo and code cleanup. #871
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/slayer')
4 files changed, 37 insertions, 7 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerBossSpawnSoon.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerBossSpawnSoon.kt index c5fd182db..d4953fb41 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerBossSpawnSoon.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerBossSpawnSoon.kt @@ -8,13 +8,19 @@ import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber import at.hannibal2.skyhanni.utils.SoundUtils 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.seconds class SlayerBossSpawnSoon { private val config get() = SkyHanniMod.feature.slayer.slayerBossWarning - private val pattern = " \\(?(?<progress>[0-9.,k]+)/(?<total>[0-9.,k]+)\\)?.*".toPattern() + + private val progressPattern by RepoPattern.pattern( + "slayer.bosswarning.progress", + " \\(?(?<progress>[0-9.,k]+)/(?<total>[0-9.,k]+)\\)?.*" + ) + private var lastCompletion = 0f private var warned = false @@ -23,7 +29,7 @@ class SlayerBossSpawnSoon { if (!isEnabled()) return if (!SlayerAPI.isInCorrectArea) return - val completion = pattern.matchMatcher(event.newProgress.removeColor()) { + val completion = progressPattern.matchMatcher(event.newProgress.removeColor()) { group("progress").formatNumber().toFloat() / group("total").formatNumber().toFloat() } ?: return diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt index f28733f59..fba389eb7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt @@ -13,6 +13,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.getLorenzVec +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.entity.EntityLivingBase import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds @@ -20,7 +21,12 @@ import kotlin.time.Duration.Companion.seconds class SlayerQuestWarning { private val config get() = SkyHanniMod.feature.slayer - private val talkToMaddoxPattern = " {3}§r§5§l» §r§7Talk to Maddox to claim your (.+) Slayer XP!".toPattern() + + private val talkToMaddoxPattern by RepoPattern.pattern( + "slayer.questwarning.talkto", + " {3}§r§5§l» §r§7Talk to Maddox to claim your .+ Slayer XP!" + ) + private var needSlayerQuest = false private var lastWarning = 0L private var currentReason = "" diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt index d471ea441..558d421d0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt @@ -20,6 +20,7 @@ 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.StringUtils.removeWordsAtEnd +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import io.github.moulberry.notenoughupdates.util.Constants import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.math.ceil @@ -28,10 +29,22 @@ import kotlin.time.Duration.Companion.seconds class SlayerRngMeterDisplay { private val config get() = SkyHanniMod.feature.slayer.rngMeterDisplay + + private val patternGroup = RepoPattern.group("slayer.rngmeter") + private val inventoryNamePattern by patternGroup.pattern( + "inventoryname", + "(?<name>.*) RNG Meter" + ) + private val updatePattern by patternGroup.pattern( + "update", + " {3}§dRNG Meter §f- §d(?<exp>.*) Stored XP" + ) + private val changedItemPattern by patternGroup.pattern( + "changeditem", + "§aYou set your §r.* RNG Meter §r§ato drop §r.*§a!" + ) + private var display = "" - private val inventoryNamePattern = "(?<name>.*) RNG Meter".toPattern() - private val updatePattern = " {3}§dRNG Meter §f- §d(?<exp>.*) Stored XP".toPattern() - private val changedItemPattern = "§aYou set your §r.* RNG Meter §r§ato drop §r.*§a!".toPattern() private var lastItemDroppedTime = 0L @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt index 5d33ca6c6..712ab3b5e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt @@ -18,6 +18,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.StringUtils.matches import at.hannibal2.skyhanni.utils.getLorenzVec +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.client.Minecraft import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -25,7 +26,11 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class BlazeSlayerDaggerHelper { private val config get() = SkyHanniMod.feature.slayer.blazes.hellion - private val attunementPattern = "§cStrike using the §r(.+) §r§cattunement on your dagger!".toPattern() + + private val attunementPattern by RepoPattern.pattern( + "slayer.blaze.dagger.attunement", + "§cStrike using the §r(.+) §r§cattunement on your dagger!" + ) private var clientSideClicked = false private var textTop = "" |