diff options
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/mining/powdertracker/PowderChestReward.kt | 105 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/mining/powdertracker/PowderTracker.kt | 45 |
2 files changed, 88 insertions, 62 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/powdertracker/PowderChestReward.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/powdertracker/PowderChestReward.kt index 19a7f8274..a54034d1e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/powdertracker/PowderChestReward.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/powdertracker/PowderChestReward.kt @@ -1,151 +1,156 @@ package at.hannibal2.skyhanni.features.mining.powdertracker -import java.util.regex.Pattern +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern -enum class PowderChestReward(val displayName: String, val pattern: Pattern) { +enum class PowderChestReward(val displayName: String, pattern: String) { - MITHRIL_POWDER("§aMithril Powder", "§aYou received §r§b[+](?<amount>.*) §r§aMithril Powder.".toPattern()), - GEMSTONE_POWDER("§dGemstone Powder", "§aYou received §r§b[+](?<amount>.*) §r§aGemstone Powder.".toPattern()), + MITHRIL_POWDER("§aMithril Powder", "§aYou received §r§b[+](?<amount>.*) §r§aMithril Powder."), + GEMSTONE_POWDER("§dGemstone Powder", "§aYou received §r§b[+](?<amount>.*) §r§aGemstone Powder."), ROUGH_RUBY_GEMSTONE( "§fRough Ruby Gemstone", - "§aYou received §r§f(?<amount>.*) §r§f❤ §r§fRough Ruby Gemstone§r§a.".toPattern() + "§aYou received §r§f(?<amount>.*) §r§f❤ Rough Ruby Gemstone§r§a." ), FLAWED_RUBY_GEMSTONE( "§aFlawed Sapphire Gemstone", - "§aYou received §r§f(?<amount>.*) §r§a❤ §r§aFlawed RubyGemstone§r§a.".toPattern() + "§aYou received §r§f(?<amount>.*) §r§a❤ Flawed RubyGemstone§r§a." ), FINE_RUBY_GEMSTONE( "§9Fine Ruby Gemstone", - "§aYou received §r§f(?<amount>.*) §r§9❤ §r§9Fine Ruby Gemstone§r§a.".toPattern() + "§aYou received §r§f(?<amount>.*) §r§9❤ Fine Ruby Gemstone§r§a." ), FLAWLESS_RUBY_GEMSTONE( "§5Flawless Ruby Gemstone", - "§aYou received §r§f(?<amount>.*) §r§9❤ §r§5Flawless Ruby Gemstone§r§a.".toPattern() + "§aYou received §r§f(?<amount>.*) §r§9❤ Flawless Ruby Gemstone§r§a." ), ROUGH_SAPPHIRE_GEMSTONE( "§fRough Sapphire Gemstone", - "§aYou received §r§f(?<amount>.*) §r§f✎ §r§fRough Sapphire Gemstone§r§a.".toPattern() + "§aYou received §r§f(?<amount>.*) §r§f✎ Rough Sapphire Gemstone§r§a." ), FLAWED_SAPPHIRE_GEMSTONE( "§aFlawed Sapphire Gemstone", - "§aYou received §r§f(?<amount>.*) §r§a✎ §r§aFlawed Sapphire Gemstone§r§a.".toPattern() + "§aYou received §r§f(?<amount>.*) §r§a✎ Flawed Sapphire Gemstone§r§a." ), FINE_SAPPHIRE_GEMSTONE( "§9Fine Sapphire Gemstone", - "§aYou received §r§f(?<amount>.*) §r§9✎ §r§9Fine Sapphire Gemstone§r§a.".toPattern() + "§aYou received §r§f(?<amount>.*) §r§9✎ Fine Sapphire Gemstone§r§a." ), FLAWLESS_SAPPHIRE_GEMSTONE( "§5Flawless Sapphire Gemstone", - "§aYou received §r§f(?<amount>.*) §r§9✎ §r§5Flawless Sapphire Gemstone§r§a.".toPattern() + "§aYou received §r§f(?<amount>.*) §r§9✎ Flawless Sapphire Gemstone§r§a." ), ROUGH_AMBER_GEMSTONE( "§fRough Amber Gemstone", - "§aYou received §r§f(?<amount>.*) §r§f⸕ §r§fRough Amber Gemstone§r§a.".toPattern() + "§aYou received §r§f(?<amount>.*) §r§f⸕ Rough Amber Gemstone§r§a." ), FLAWED_AMBER_GEMSTONE( "§aFlawed Amber Gemstone", - "§aYou received §r§f(?<amount>.*) §r§a⸕ §r§aFlawed Amber Gemstone§r§a.".toPattern() + "§aYou received §r§f(?<amount>.*) §r§a⸕ Flawed Amber Gemstone§r§a." ), FINE_AMBER_GEMSTONE( "§9Fine Amber Gemstone", - "§aYou received §r§f(?<amount>.*) §r§9⸕ §r§9Fine Amber Gemstone§r§a.".toPattern() + "§aYou received §r§f(?<amount>.*) §r§9⸕ Fine Amber Gemstone§r§a." ), FLAWLESS_AMBER_GEMSTONE( "§5Flawless Amber Gemstone", - "§aYou received §r§f(?<amount>.*) §r§9⸕ §r§5Flawless Amber Gemstone§r§a.".toPattern() + "§aYou received §r§f(?<amount>.*) §r§9⸕ Flawless Amber Gemstone§r§a." ), ROUGH_AMETHYST_GEMSTONE( "§fRough Amethyst Gemstone", - "§aYou received §r§f(?<amount>.*) §r§f❈ §r§fRough Amethyst Gemstone§r§a.".toPattern() + "§aYou received §r§f(?<amount>.*) §r§f❈ Rough Amethyst Gemstone§r§a." ), FLAWED_AMETHYST_GEMSTONE( "§aFlawed Amethyst Gemstone", - "§aYou received §r§f(?<amount>.*) §r§a❈ §r§aFlawed Amethyst Gemstone§r§a.".toPattern() + "§aYou received §r§f(?<amount>.*) §r§a❈ Flawed Amethyst Gemstone§r§a." ), FINE_AMETHYST_GEMSTONE( "§9Fine Amethyst Gemstone", - "§aYou received §r§f(?<amount>.*) §r§9❈ §r§9Fine Amethyst Gemstone§r§a.".toPattern() + "§aYou received §r§f(?<amount>.*) §r§9❈ Fine Amethyst Gemstone§r§a." ), FLAWLESS_AMETHYST_GEMSTONE( "§5Flawless Amethyst Gemstone", - "§aYou received §r§f(?<amount>.*) §r§9❈ §r§5Flawless Amethyst Gemstone§r§a.".toPattern() + "§aYou received §r§f(?<amount>.*) §r§9❈ Flawless Amethyst Gemstone§r§a." ), ROUGH_JADE_GEMSTONE( "§fRough Jade Gemstone", - "§aYou received §r§f(?<amount>.*) §r§f☘ §r§fRough Jade Gemstone§r§a.".toPattern() + "§aYou received §r§f(?<amount>.*) §r§f☘ Rough Jade Gemstone§r§a." ), FLAWED_JADE_GEMSTONE( "§aFlawed Jade Gemstone", - "§aYou received §r§f(?<amount>.*) §r§a☘ §r§aFlawed Jade Gemstone§r§a.".toPattern() + "§aYou received §r§f(?<amount>.*) §r§a☘ Flawed Jade Gemstone§r§a." ), FINE_JADE_GEMSTONE( "§9Fine Jade Gemstone", - "§aYou received §r§f(?<amount>.*) §r§9☘ §r§9Fine Jade Gemstone§r§a.".toPattern() + "§aYou received §r§f(?<amount>.*) §r§9☘ Fine Jade Gemstone§r§a." ), FLAWLESS_JADE_GEMSTONE( "§5Flawless Jade Gemstone", - "§aYou received §r§f(?<amount>.*) §r§9☘ §r§5Flawless Jade Gemstone§r§a.".toPattern() + "§aYou received §r§f(?<amount>.*) §r§9☘ §r§5Flawless Jade Gemstone§r§a." ), ROUGH_TOPAZ_GEMSTONE( "§fRough Topaz Gemstone", - "§aYou received §r§f(?<amount>.*) §r§f✧ §r§fRough Topaz Gemstone§r§a.".toPattern() + "§aYou received §r§f(?<amount>.*) §r§f✧ Rough Topaz Gemstone§r§a." ), FLAWED_TOPAZ_GEMSTONE( "§aFlawed Topaz Gemstone", - "§aYou received §r§f(?<amount>.*) §r§a✧ §r§aFlawed Topaz Gemstone§r§a.".toPattern() + "§aYou received §r§f(?<amount>.*) §r§a✧ Flawed Topaz Gemstone§r§a." ), FINE_TOPAZ_GEMSTONE( "§9Fine Topaz Gemstone", - "§aYou received §r§f(?<amount>.*) §r§9✧ §r§9Fine Topaz Gemstone§r§a.".toPattern() + "§aYou received §r§f(?<amount>.*) §r§9✧ Fine Topaz Gemstone§r§a." ), FLAWLESS_TOPAZ_GEMSTONE( "§5Flawless Topaz Gemstone", - "§aYou received §r§f(?<amount>.*) §r§9✧ §r§5Flawless Topaz Gemstone§r§a.".toPattern() + "§aYou received §r§f(?<amount>.*) §r§9✧ Flawless Topaz Gemstone§r§a." ), - FTX_3070("§9FTX 3070", "§aYou received §r§f(?<amount>.*) §r§9FTX 3070§r§a.".toPattern()), + FTX_3070("§9FTX 3070", "§aYou received §r§f(?<amount>.*) §r§9FTX 3070§r§a."), ELECTRON_TRANSIMTTER( "§9Electron Transmitter", - "§aYou received §r§f(?<amount>.*) §r§9Electron Transmitter§r§a.".toPattern() + "§aYou received §r§f(?<amount>.*) §r§9Electron Transmitter§r§a." ), ROBOTRON_REFLECTOR( "§9Robotron Reflector", - "§aYou received §r§f(?<amount>.*) §r§9Robotron Reflector§r§a.".toPattern() + "§aYou received §r§f(?<amount>.*) §r§9Robotron Reflector§r§a." ), - SUPERLITE_MOTOR("§9Superlite Motor", "§aYou received §r§f(?<amount>.*) §r§9Superlite Motor§r§a.".toPattern()), - CONTROL_SWITCH("§9Control Switch", "§aYou received §r§f(?<amount>.*) §r§9Control Switch§r§a.".toPattern()), - SYNTHETIC_HEART("§9Synthetic Heart", "§aYou received §r§f(?<amount>.*) §r§9Synthetic Heart§r§a.".toPattern()), + SUPERLITE_MOTOR("§9Superlite Motor", "§aYou received §r§f(?<amount>.*) §r§9Superlite Motor§r§a."), + CONTROL_SWITCH("§9Control Switch", "§aYou received §r§f(?<amount>.*) §r§9Control Switch§r§a."), + SYNTHETIC_HEART("§9Synthetic Heart", "§aYou received §r§f(?<amount>.*) §r§9Synthetic Heart§r§a."), - GOBLIN_EGG("§9Goblin Egg", "§aYou received §r§f(?<amount>.*) §r§9Goblin Egg§r§a.".toPattern()), + GOBLIN_EGG("§9Goblin Egg", "§aYou received §r§f(?<amount>.*) §r§9Goblin Egg§r§a."), GREEN_GOBLIN_EGG( "§aGreen Goblin Egg", - "§aYou received §r§f(?<amount>.*) §r§a§r§aGreen Goblin Egg§r§a.".toPattern() + "§aYou received §r§f(?<amount>.*) §r§a§r§aGreen Goblin Egg§r§a." ), - RED_GOBLIN_EGG("§cRed Goblin Egg", "§aYou received §r§f(?<amount>.*) §r§9§r§cRed Goblin Egg§r§a.".toPattern()), + RED_GOBLIN_EGG("§cRed Goblin Egg", "§aYou received §r§f(?<amount>.*) §r§9§r§cRed Goblin Egg§r§a."), YELLOW_GOBLIN_EGG( "§eYellow Goblin Egg", - "§aYou received §r§f(?<amount>.*) §r§9§r§eYellow Goblin Egg§r§a.".toPattern() + "§aYou received §r§f(?<amount>.*) §r§9§r§eYellow Goblin Egg§r§a." ), - BLUE_GOBLIN_EGG("§3Blue Goblin Egg", "§aYou received §r§f(?<amount>.*) §r§9§r§3Blue Goblin Egg§r§a.".toPattern()), + BLUE_GOBLIN_EGG("§3Blue Goblin Egg", "§aYou received §r§f(?<amount>.*) §r§9§r§3Blue Goblin Egg§r§a."), - WISHING_COMPASS("§aWishing Compass", "§aYou received §r§f(?<amount>.*) §r§aWishing Compass§r§a.".toPattern()), + WISHING_COMPASS("§aWishing Compass", "§aYou received §r§f(?<amount>.*) §r§aWishing Compass§r§a."), - SLUDGE_JUICE("§aSludge Juice", "§aYou received §r§f(?<amount>.*) §r§aSludge Juice§r§a.".toPattern()), - ASCENSION_ROPE("§9Ascension Rope", "§aYou received §r§f(?<amount>.*) §r§9Ascension Rope§r§a.".toPattern()), - TREASURITE("§5Treasurite", "§aYou received §r§f(?<amount>.*) §r§5Treasurite§r§a.".toPattern()), - JUNGLE_HEART("§6Jungle Heart", "§aYou received §r§f(?<amount>.*) §r§6Jungle Heart§r§a.".toPattern()), - PICKONIMBUS_2000("§5Pickonimbus 2000", "§aYou received §r§f(?<amount>.*) §r§5Pickonimbus 2000§r§a.".toPattern()), - YOGGIE("§aYoggie", "§aYou received §r§f(?<amount>.*) §r§aYoggie§r§a.".toPattern()), - PREHISTORIC_EGG("§fPrehistoric Egg", "§aYou received §r§f(?<amount>.*) §r§fPrehistoric Egg§r§a.".toPattern()), - OIL_BARREL("§aOil Barrel", "§aYou received §r§f(?<amount>.*) §r§aOil Barrel§r§a.".toPattern()), + SLUDGE_JUICE("§aSludge Juice", "§aYou received §r§f(?<amount>.*) §r§aSludge Juice§r§a."), + ASCENSION_ROPE("§9Ascension Rope", "§aYou received §r§f(?<amount>.*) §r§9Ascension Rope§r§a."), + TREASURITE("§5Treasurite", "§aYou received §r§f(?<amount>.*) §r§5Treasurite§r§a."), + JUNGLE_HEART("§6Jungle Heart", "§aYou received §r§f(?<amount>.*) §r§6Jungle Heart§r§a."), + PICKONIMBUS_2000("§5Pickonimbus 2000", "§aYou received §r§f(?<amount>.*) §r§5Pickonimbus 2000§r§a."), + YOGGIE("§aYoggie", "§aYou received §r§f(?<amount>.*) §r§aYoggie§r§a."), + PREHISTORIC_EGG("§fPrehistoric Egg", "§aYou received §r§f(?<amount>.*) §r§fPrehistoric Egg§r§a."), + OIL_BARREL("§aOil Barrel", "§aYou received §r§f(?<amount>.*) §r§aOil Barrel§r§a."), - DIAMOND_ESSENCE("§bDiamond Essence", "§aYou received §r§b[+](?<amount>.*) Diamond Essence".toPattern()), - GOLD_ESSENCE("§6Gold Essence", "§aYou received §r§6[+](?<amount>.*) Gold Essence".toPattern()), + DIAMOND_ESSENCE("§bDiamond Essence", "§aYou received §r§b[+](?<amount>.*) Diamond Essence"), + GOLD_ESSENCE("§6Gold Essence", "§aYou received §r§6[+](?<amount>.*) Gold Essence"), + ; + + val chatPattern by RepoPattern.pattern("mining.powder.tracker.reward." + this.patternName(), pattern) + + private fun PowderChestReward.patternName() = name.lowercase().replace("_", "") } diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/powdertracker/PowderTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/powdertracker/PowderTracker.kt index 792f4a901..9a9c49ff2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/powdertracker/PowderTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/powdertracker/PowderTracker.kt @@ -17,6 +17,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import at.hannibal2.skyhanni.utils.tracker.SkyHanniTracker import at.hannibal2.skyhanni.utils.tracker.TrackerData import com.google.gson.JsonArray @@ -29,11 +30,29 @@ import kotlin.concurrent.fixedRateTimer object PowderTracker { private val config get() = SkyHanniMod.feature.mining.powderTracker - private val picked = "§6You have successfully picked the lock on this chest!".toPattern() - private val uncovered = "§aYou uncovered a treasure chest!".toPattern() - private val powderEvent = ".*§r§b§l2X POWDER STARTED!.*".toPattern() - private val powderEnded = ".*§r§b§l2X POWDER ENDED!.*".toPattern() - private val powderBossBar = "§e§lPASSIVE EVENT §b§l2X POWDER §e§lRUNNING FOR §a§l(?<time>.*)§r".toPattern() + + private val patternGroup = RepoPattern.group("mining.powder.tracker") + private val pickedPattern by patternGroup.pattern( + "picked", + "§6You have successfully picked the lock on this chest!" + ) + private val uncoveredPattern by patternGroup.pattern( + "uncovered", + "§aYou uncovered a treasure chest!" + ) + private val powderStartedPattern by patternGroup.pattern( + "powder.started", + ".*§r§b§l2X POWDER ENDED!.*" + ) + private val powderEndedPattern by patternGroup.pattern( + "powder.ended", + ".*§r§b§l2X POWDER STARTED!.*" + ) + private val powderBossBarPattern by patternGroup.pattern( + "powder.bossbar", + "§e§lPASSIVE EVENT §b§l2X POWDER §e§lRUNNING FOR §a§l(?<time>.*)§r" + ) + private var lastChestPicked = 0L private var isGrinding = false private val gemstoneInfo = ResourceInfo(0L, 0L, 0, 0.0, mutableListOf()) @@ -53,6 +72,8 @@ object PowderTracker { ) init { + PowderChestReward.entries.forEach { it.chatPattern } + fixedRateTimer(name = "skyhanni-powder-tracker", period = 1000) { if (!isEnabled()) return@fixedRateTimer calculateResourceHour(gemstoneInfo) @@ -94,7 +115,7 @@ object PowderTracker { val msg = event.message if (config.greatExplorerMaxed) { - uncovered.matchMatcher(msg) { + uncoveredPattern.matchMatcher(msg) { tracker.modify { it.totalChestPicked += 1 } @@ -103,7 +124,7 @@ object PowderTracker { } } - picked.matchMatcher(msg) { + pickedPattern.matchMatcher(msg) { tracker.modify { it.totalChestPicked += 1 } @@ -111,11 +132,11 @@ object PowderTracker { lastChestPicked = System.currentTimeMillis() } - powderEvent.matchMatcher(msg) { doublePowder = true } - powderEnded.matchMatcher(msg) { doublePowder = false } + powderStartedPattern.matchMatcher(msg) { doublePowder = true } + powderEndedPattern.matchMatcher(msg) { doublePowder = false } for (reward in PowderChestReward.entries) { - reward.pattern.matchMatcher(msg) { + reward.chatPattern.matchMatcher(msg) { tracker.modify { val count = it.rewards[reward] ?: 0 var amount = group("amount").formatNumber() @@ -132,8 +153,8 @@ object PowderTracker { fun onTick(event: LorenzTickEvent) { if (!isEnabled()) return if (event.repeatSeconds(1)) { - doublePowder = powderBossBar.matcher(BossStatus.bossName).find() - powderBossBar.matchMatcher(BossStatus.bossName) { + doublePowder = powderBossBarPattern.matcher(BossStatus.bossName).find() + powderBossBarPattern.matchMatcher(BossStatus.bossName) { powderTimer = group("time") doublePowder = powderTimer != "00:00" |