diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-04-17 23:08:50 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-04-17 23:08:50 +0200 |
commit | a1e0e192ba5c7e12bf2edbfadefe286d7503f188 (patch) | |
tree | 5d1ad0a75706857d58eb7e61e68bb58ca902e8a0 /src/main/java/at/hannibal2/skyhanni/features | |
parent | 9991622e4407d05cc140d6f30ff55c073cbffaa8 (diff) | |
download | skyhanni-a1e0e192ba5c7e12bf2edbfadefe286d7503f188.tar.gz skyhanni-a1e0e192ba5c7e12bf2edbfadefe286d7503f188.tar.bz2 skyhanni-a1e0e192ba5c7e12bf2edbfadefe286d7503f188.zip |
to Pattern
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
30 files changed, 52 insertions, 79 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarCancelledBuyOrderClipboard.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarCancelledBuyOrderClipboard.kt index c5fe44328..b7f343436 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarCancelledBuyOrderClipboard.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarCancelledBuyOrderClipboard.kt @@ -14,7 +14,7 @@ class BazaarCancelledBuyOrderClipboard { private val patternLastAmount = Pattern.compile("§a(.*)§7x") private val patternCancelledMessage = - Pattern.compile("§6\\[Bazaar] §r§7§r§cCancelled! §r§7Refunded §r§6(.*) coins §r§7from cancelling Buy Order!") + "§6\\[Bazaar] §r§7§r§cCancelled! §r§7Refunded §r§6(.*) coins §r§7from cancelling Buy Order!".toPattern() private var latestAmount: String? = null diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt index b00a7de19..cc4faeaeb 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt @@ -18,7 +18,6 @@ import net.minecraft.client.gui.inventory.GuiChest import net.minecraft.inventory.ContainerChest import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.TickEvent -import java.util.regex.Pattern class BingoCardDisplay { @@ -28,7 +27,7 @@ class BingoCardDisplay { private var tick = 0 private var display = listOf<String>() private val config get() = SkyHanniMod.feature.bingo - private val goalCompletePattern = Pattern.compile("§6§lBINGO GOAL COMPLETE! §r§e(.*)") + private val goalCompletePattern = "§6§lBINGO GOAL COMPLETE! §r§e(.*)".toPattern() init { update() diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoNextStepHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoNextStepHelper.kt index 2423ed85d..28faaf877 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoNextStepHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoNextStepHelper.kt @@ -14,7 +14,6 @@ import at.hannibal2.skyhanni.utils.StringUtils.matchRegex import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.TickEvent -import java.util.regex.Pattern class BingoNextStepHelper { private var tick = 0 @@ -23,8 +22,9 @@ class BingoNextStepHelper { private val itemIslandRequired = mutableMapOf<String, IslandVisitStep>() private val itemRequired = mutableMapOf<String, NextStep>() private val islands = mutableMapOf<IslandType, IslandVisitStep>() - private val collectionPattern = Pattern.compile("Reach ([0-9]+(?:,\\d+)*) (.*) Collection\\.") - private val crystalPattern = Pattern.compile("Obtain a (\\w+) Crystal in the Crystal Hollows\\.") + private val collectionPattern = "Reach ([0-9]+(?:,\\d+)*) (.*) Collection\\.".toPattern() + private val crystalPattern = "Obtain a (\\w+) Crystal in the Crystal Hollows\\.".toPattern() + private val skillPattern = "Obtain level (.*) in the (.*) Skill.".toPattern() companion object { private val finalSteps = mutableListOf<NextStep>() @@ -251,8 +251,7 @@ class BingoNextStepHelper { val crystal = crystalMatcher.group(1) ChatMessageStep("Obtain a $crystal Crystal").apply { finalSteps.add(this) } requires IslandType.CRYSTAL_HOLLOWS.getStep() } - val pattern = Pattern.compile("Obtain level (.*) in the (.*) Skill.") - val matcher = pattern.matcher(description) + val matcher = skillPattern.matcher(description) if (matcher.matches()) { val level = matcher.group(1).toInt() val skillName = matcher.group(2) diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt index 72251046b..6fb885ff2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt @@ -19,10 +19,9 @@ import net.minecraft.item.ItemStack import net.minecraftforge.event.world.WorldEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.TickEvent -import java.util.regex.Pattern class MinionCraftHelper { - private var minionNamePattern = Pattern.compile("(.*) Minion (.*)") + private var minionNamePattern = "(.*) Minion (.*)".toPattern() private var tick = 0 private var display = listOf<String>() private var hasMinionInInventory = false diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerDeathMessages.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerDeathMessages.kt index 3c2e7306d..1de8f09a2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerDeathMessages.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerDeathMessages.kt @@ -11,7 +11,6 @@ import net.minecraft.client.Minecraft import net.minecraft.client.entity.EntityOtherPlayerMP import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.TickEvent -import java.util.regex.Pattern class PlayerDeathMessages { @@ -19,7 +18,7 @@ class PlayerDeathMessages { private val lastTimePlayerSeen = mutableMapOf<String, Long>() //§c ☠ §r§7§r§bZeroHazel§r§7 was killed by §r§8§lAshfang§r§7§r§7. - private val pattern = Pattern.compile("§c ☠ §r§7§r§.(.+)§r§7 (.+)") + private val pattern = "§c ☠ §r§7§r§.(.+)§r§7 (.+)".toPattern() @SubscribeEvent fun onTick(event: TickEvent.ClientTickEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt index 998106a48..ca053323f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt @@ -34,7 +34,6 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.TickEvent import java.util.* -import java.util.regex.Pattern import kotlin.math.max class DamageIndicatorManager { @@ -45,7 +44,7 @@ class DamageIndicatorManager { companion object { private var data = mutableMapOf<UUID, EntityData>() - private val damagePattern = Pattern.compile("[✧✯]?(\\d+[⚔+✧❤♞☄✷ﬗ✯]*)") + private val damagePattern = "[✧✯]?(\\d+[⚔+✧❤♞☄✷ﬗ✯]*)".toPattern() fun isBoss(entity: EntityLivingBase): Boolean { return data.values.any { it.entity == entity } diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonData.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonData.kt index 9b5430b93..00db6d6b8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonData.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonData.kt @@ -9,11 +9,10 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraftforge.event.world.WorldEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.TickEvent -import java.util.regex.Pattern class DungeonData { - private val pattern = Pattern.compile(" §7⏣ §cThe Catacombs §7\\((.*)\\)") + private val pattern = " §7⏣ §cThe Catacombs §7\\((.*)\\)".toPattern() companion object { var dungeonFloor: String? = null diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLevelColor.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLevelColor.kt index ff334737b..91b347145 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLevelColor.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLevelColor.kt @@ -6,11 +6,10 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraftforge.event.entity.player.ItemTooltipEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import java.util.regex.Pattern class DungeonLevelColor { - private val pattern = Pattern.compile(" §.(.*)§f: §e(.*)§b \\(§e(.*)§b\\)") + private val pattern = " §.(.*)§f: §e(.*)§b \\(§e(.*)§b\\)".toPattern() @SubscribeEvent fun onItemTooltip(event: ItemTooltipEvent) { 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 54dbb21a4..112ef5a1f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt @@ -12,20 +12,19 @@ import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNeeded import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import java.util.regex.Pattern import kotlin.math.roundToInt class GardenLevelDisplay { private val config get() = SkyHanniMod.feature.garden - private val overflowPattern = Pattern.compile("(?:.*) §e(.*)§6\\/(?:.*)") - private val namePattern = Pattern.compile("Garden Level (.*)") + private val overflowPattern = "(?:.*) §e(.*)§6\\/(?:.*)".toPattern() + private val namePattern = "Garden Level (.*)".toPattern() private var gardenExp get() = SkyHanniMod.feature.hidden.gardenExp set(value) { SkyHanniMod.feature.hidden.gardenExp = value } private var display = "" - private var visitorRewardPattern = Pattern.compile(" {4}§r§8\\+§r§2(.*) §r§7Garden Experience") + private var visitorRewardPattern = " {4}§r§8\\+§r§2(.*) §r§7Garden Experience".toPattern() @SubscribeEvent fun onProfileJoin(event: ProfileJoinEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt index 1fcb470b4..c5c5d6978 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt @@ -15,7 +15,6 @@ import io.github.moulberry.notenoughupdates.util.SkyBlockTime import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.TickEvent import java.time.Instant -import java.util.regex.Pattern class GardenNextJacobContest { private var display = listOf<Any>() @@ -23,9 +22,9 @@ class GardenNextJacobContest { private var tick = 0 private var contests = mutableMapOf<Long, FarmingContest>() private var inCalendar = false - private val patternDay = Pattern.compile("§aDay (.*)") - private val patternMonth = Pattern.compile("(.*), Year (.*)") - private val patternCrop = Pattern.compile("§e○ §7(.*)") + private val patternDay = "§aDay (.*)".toPattern() + private val patternMonth = "(.*), Year (.*)".toPattern() + private val patternCrop = "§e○ §7(.*)".toPattern() private val maxContestsPerYear = 124 private val contestDuration = 1_000 * 60 * 20 diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt index cab83ecb3..d131aa91a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt @@ -16,14 +16,13 @@ import net.minecraft.client.gui.inventory.GuiEditSign import net.minecraftforge.client.event.GuiOpenEvent import net.minecraftforge.client.event.GuiScreenEvent.DrawScreenEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import java.util.regex.Pattern class GardenOptimalSpeed { private val config get() = SkyHanniMod.feature.garden private val configCustomSpeed get() = config.optimalSpeedCustom private var currentSpeed = 100 private var optimalSpeed = -1 - private val currentSpeedPattern = Pattern.compile(" Speed: §r§f✦(.*)") + private val currentSpeedPattern = " Speed: §r§f✦(.*)".toPattern() private var lastWarnTime = 0L private var cropInHand: CropType? = null private var rancherOverlayList: List<List<Any?>> = emptyList() diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenTeleportPadCompactName.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenTeleportPadCompactName.kt index 95e50dff2..4dcd73745 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenTeleportPadCompactName.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenTeleportPadCompactName.kt @@ -6,11 +6,10 @@ import net.minecraft.entity.item.EntityArmorStand import net.minecraftforge.client.event.RenderLivingEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import java.util.regex.Pattern class GardenTeleportPadCompactName { - private val patternName = Pattern.compile("§.✦ §aWarp To (.*)") - private val patternNoName = Pattern.compile("§.✦ §cNo Destination") + private val patternName = "§.✦ §aWarp To (.*)".toPattern() + private val patternNoName = "§.✦ §cNo Destination".toPattern() @SubscribeEvent(priority = EventPriority.HIGH) fun onRenderLivingB(event: RenderLivingEvent.Specials.Pre<EntityLivingBase>) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterDisplay.kt index 9914f756f..ba9cbe9a1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterDisplay.kt @@ -11,7 +11,6 @@ import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems import at.hannibal2.skyhanni.utils.TimeUtils import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import java.util.regex.Pattern import kotlin.time.Duration import kotlin.time.DurationUnit @@ -23,7 +22,7 @@ class ComposterDisplay { private var tabListData by ComposterAPI::tabListData - enum class DataType(val pattern: String, val icon: String) { + enum class DataType(rawPattern: String, val icon: String) { ORGANIC_MATTER(" Organic Matter: §r(.*)", "WHEAT"), FUEL(" Fuel: §r(.*)", "OIL_BARREL"), TIME_LEFT(" Time Left: §r(.*)", "WATCH"), @@ -33,6 +32,8 @@ class ComposterDisplay { NEUItems.getItemStack(icon) } + val pattern by lazy {rawPattern.toPattern()} + fun addToList(map: Map<DataType, String>): List<Any> { return listOf(displayItem, map[this]!!) } @@ -114,8 +115,7 @@ class ComposterDisplay { if (next) { if (line == "") break for (type in DataType.values()) { - val pattern = Pattern.compile(type.pattern) - val matcher = pattern.matcher(line) + val matcher = type.pattern.matcher(line) if (matcher.matches()) { newData[type] = matcher.group(1) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterInventoryNumbers.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterInventoryNumbers.kt index 51e30ef16..1ebf0dfe3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterInventoryNumbers.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterInventoryNumbers.kt @@ -7,11 +7,10 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import java.util.regex.Pattern class ComposterInventoryNumbers { - private val valuePattern = Pattern.compile("(?:.*) §e(.*)§6\\/(.*)") - private val compostsPattern = Pattern.compile("§7§7Compost Available: §a(.*)") + private val valuePattern = "(?:.*) §e(.*)§6\\/(.*)".toPattern() + private val compostsPattern = "§7§7Compost Available: §a(.*)".toPattern() @SubscribeEvent fun onRenderItemTip(event: RenderInventoryItemTipEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingArmorDrops.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingArmorDrops.kt index 80b922af2..2423f1a62 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingArmorDrops.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingArmorDrops.kt @@ -12,14 +12,13 @@ import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.TickEvent -import java.util.regex.Pattern class FarmingArmorDrops { private var display = listOf<String>() private val drops = mutableMapOf<ArmorDropType, Int>() private var hasArmor = false private var tick = 0 - private val armorPattern = Pattern.compile("(FERMENTO|CROPIE|SQUASH|MELON)_(LEGGINGS|CHESTPLATE|BOOTS|HELMET)") + private val armorPattern = "(FERMENTO|CROPIE|SQUASH|MELON)_(LEGGINGS|CHESTPLATE|BOOTS|HELMET)".toPattern() private val config get() = SkyHanniMod.feature.garden enum class ArmorDropType(val dropName: String, val chatMessage: String) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenInventoryNumbers.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenInventoryNumbers.kt index a68838876..c2003186a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenInventoryNumbers.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenInventoryNumbers.kt @@ -9,11 +9,10 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNeeded import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import java.util.regex.Pattern class GardenInventoryNumbers { - private var patternTierProgress = Pattern.compile("§7Progress to Tier (.*): §e(?:.*)") - private var patternUpgradeTier = Pattern.compile("§7Current Tier: §[ea](.*)§7/§a.*") + private var patternTierProgress = "§7Progress to Tier (.*): §e(?:.*)".toPattern() + private var patternUpgradeTier = "§7Current Tier: §[ea](.*)§7/§a.*".toPattern() @SubscribeEvent fun onRenderItemTip(event: RenderItemTipEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/SkyMartCopperPrice.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/SkyMartCopperPrice.kt index 4aa36fd23..3a83ff92b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/SkyMartCopperPrice.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/SkyMartCopperPrice.kt @@ -14,10 +14,9 @@ import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import java.util.regex.Pattern class SkyMartCopperPrice { - private val pattern = Pattern.compile("§c(.*) Copper") + private val pattern = "§c(.*) Copper".toPattern() private var display = listOf<List<Any>>() private val config get() = SkyHanniMod.feature.garden diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt index 0b86ac8cc..e5a113001 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt @@ -34,16 +34,15 @@ import net.minecraftforge.event.entity.player.ItemTooltipEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.TickEvent -import java.util.regex.Pattern class GardenVisitorFeatures { private val visitors = mutableMapOf<String, Visitor>() private var display = listOf<List<Any>>() private var lastClickedNpc = 0 private var tick = 0 - private val newVisitorArrivedMessage = Pattern.compile(".* §r§ehas arrived on your §r§bGarden§r§e!") - private val copperPattern = Pattern.compile(" §8\\+§c(.*) Copper") - private val gardenExperiencePattern = Pattern.compile(" §8\\+§2(.*) §7Garden Experience") + private val newVisitorArrivedMessage = ".* §r§ehas arrived on your §r§bGarden§r§e!".toPattern() + private val copperPattern = " §8\\+§c(.*) Copper".toPattern() + private val gardenExperiencePattern = " §8\\+§2(.*) §7Garden Experience".toPattern() private val config get() = SkyHanniMod.feature.garden companion object { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorTimer.kt index 9683dc8cc..8e2ba8f9f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorTimer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorTimer.kt @@ -11,12 +11,11 @@ import at.hannibal2.skyhanni.utils.TimeUtils import net.minecraftforge.event.world.WorldEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import java.util.regex.Pattern import kotlin.math.roundToLong class GardenVisitorTimer { - private val patternNextVisitor = Pattern.compile(" Next Visitor: §r§b(.*)") - private val patternVisitors = Pattern.compile("§b§lVisitors: §r§f\\((\\d)\\)") + private val patternNextVisitor = " Next Visitor: §r§b(.*)".toPattern() + private val patternVisitors = "§b§lVisitors: §r§f\\((\\d)\\)".toPattern() private var render = "" private var lastMillis = 0L private var lastVisitors: Int = -1 diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt index d72877007..25a899942 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt @@ -15,12 +15,11 @@ import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNeeded import at.hannibal2.skyhanni.utils.StringUtils.matchRegex import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import java.util.regex.Pattern class ItemDisplayOverlayFeatures { - private val wishingCompassPattern = Pattern.compile("§7Remaining Uses: §e(.*)§8/§e3") - private val rangerBootsSpeedCapPattern = Pattern.compile("§7Current Speed Cap: §a(.*)") + private val wishingCompassPattern = "§7Remaining Uses: §e(.*)§8/§e3".toPattern() + private val rangerBootsSpeedCapPattern = "§7Current Speed Cap: §a(.*)".toPattern() @SubscribeEvent fun onRenderItemTip(event: RenderItemTipEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemStars.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemStars.kt index af27b8f45..845262e91 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemStars.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemStars.kt @@ -8,13 +8,12 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraftforge.event.entity.player.ItemTooltipEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import java.util.regex.Pattern class ItemStars { private val armorNames = mutableListOf<String>() private val tiers = mutableMapOf<String, Int>() - private val STAR_FIND_PATCHER = Pattern.compile("(.*)§.✪(.*)") + private val STAR_FIND_PATCHER = "(.*)§.✪(.*)".toPattern() private val armorParts = listOf("Helmet", "Chestplate", "Leggings", "Boots") @SubscribeEvent(priority = EventPriority.LOW) diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/JacobFarmingContestsInventory.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/JacobFarmingContestsInventory.kt index f21bbbbb8..3eccc0cfe 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/JacobFarmingContestsInventory.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/JacobFarmingContestsInventory.kt @@ -17,7 +17,6 @@ import net.minecraft.inventory.ContainerChest import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.text.SimpleDateFormat import java.util.* -import java.util.regex.Pattern class JacobFarmingContestsInventory { @@ -26,7 +25,7 @@ class JacobFarmingContestsInventory { private val formatDay = SimpleDateFormat("dd MMMM yyyy", Locale.US) private val formatTime = SimpleDateFormat("HH:mm", Locale.US) - private val pattern = Pattern.compile("§a(.*) (.*)(?:rd|st|nd|th), Year (.*)") + private val pattern = "§a(.*) (.*)(?:rd|st|nd|th), Year (.*)".toPattern() private val config get() = SkyHanniMod.feature.inventory // Render the contests a tick delayed to feel smoother diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/StatsTuning.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/StatsTuning.kt index dd17caf48..f3ec32f1e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/StatsTuning.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/StatsTuning.kt @@ -11,11 +11,10 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.highlight import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import java.util.regex.Pattern class StatsTuning { - private val patternStatPoints = Pattern.compile("§7Stat has: §e(\\d+) point(s)?") + private val patternStatPoints = "§7Stat has: §e(\\d+) point(s)?".toPattern() @SubscribeEvent fun onRenderItemTip(event: RenderInventoryItemTipEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt index e17e54263..d04372b32 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt @@ -27,7 +27,6 @@ import net.minecraftforge.fml.common.gameevent.InputEvent import net.minecraftforge.fml.common.gameevent.TickEvent import org.lwjgl.input.Mouse import java.awt.Color -import java.util.regex.Pattern class MinionFeatures { private val config get() = SkyHanniMod.feature.minions @@ -40,7 +39,7 @@ class MinionFeatures { private var lastMinionPickedUp = 0L private val minions = mutableMapOf<LorenzVec, MinionData>() private var coinsPerDay = "" - private val minionUpgradePattern = Pattern.compile("§aYou have upgraded your Minion to Tier (.*)") + private val minionUpgradePattern = "§aYou have upgraded your Minion to Tier (.*)".toPattern() @SubscribeEvent fun onConfigLoad(event: ConfigLoadEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/CompactSplashPotionMessage.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/CompactSplashPotionMessage.kt index c5e465b54..b5851136b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/CompactSplashPotionMessage.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/CompactSplashPotionMessage.kt @@ -6,15 +6,14 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraft.util.ChatComponentText import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import java.util.regex.Pattern class CompactSplashPotionMessage { private val POTION_EFFECT_PATTERN = - Pattern.compile("§a§lBUFF! §fYou have gained §r(.*)§r§f! Press TAB or type /effects to view your active effects!") + "§a§lBUFF! §fYou have gained §r(.*)§r§f! Press TAB or type /effects to view your active effects!".toPattern() private val POTION_EFFECT_OTHERS_PATTERN = - Pattern.compile("§a§lBUFF! §fYou were splashed by (.*) §fwith §r(.*)§r§f! Press TAB or type /effects to view your active effects!") + "§a§lBUFF! §fYou were splashed by (.*) §fwith §r(.*)§r§f! Press TAB or type /effects to view your active effects!".toPattern() @SubscribeEvent fun onChatMessage(event: LorenzChatEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt index 93b5f791e..4cdbffab5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt @@ -18,7 +18,6 @@ import net.minecraftforge.event.world.WorldEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.TickEvent -import java.util.regex.Pattern class NonGodPotEffectDisplay { @@ -44,7 +43,7 @@ class NonGodPotEffectDisplay { "GABAGOEY" to "§9Gabagoey Mixin", ) - private var patternEffectsCount = Pattern.compile("§7You have §e(\\d+) §7non-god effects\\.") + private var patternEffectsCount = "§7You have §e(\\d+) §7non-god effects\\.".toPattern() private var totalEffectsCount = 0 @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailykuudra/DailyKuudraBossHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailykuudra/DailyKuudraBossHelper.kt index e8d69aa38..c6bb2d7bc 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailykuudra/DailyKuudraBossHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailykuudra/DailyKuudraBossHelper.kt @@ -14,11 +14,10 @@ import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText import net.minecraftforge.client.event.RenderWorldLastEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import java.util.regex.Pattern class DailyKuudraBossHelper(private val reputationHelper: CrimsonIsleReputationHelper) { val kuudraTiers = mutableListOf<KuudraTier>() - private val pattern = Pattern.compile(" Kuudra's Hollow \\(T(.*)\\)") + private val pattern = " Kuudra's Hollow \\(T(.*)\\)".toPattern() private var kuudraLocation: LorenzVec? = null private var allKuudraDone = true diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/DailyMiniBossHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/DailyMiniBossHelper.kt index 2e0673746..23c704811 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/DailyMiniBossHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/DailyMiniBossHelper.kt @@ -16,7 +16,6 @@ import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText import net.minecraftforge.client.event.RenderWorldLastEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import java.util.regex.Pattern class DailyMiniBossHelper(private val reputationHelper: CrimsonIsleReputationHelper) { @@ -117,9 +116,9 @@ class DailyMiniBossHelper(private val reputationHelper: CrimsonIsleReputationHel for ((displayName, extraData) in jsonElement.asJsonObject.entrySet()) { val data = extraData.asJsonObject val displayItem = data["item"]?.asString - val patterns = " *§r§6§l${displayName.uppercase()} DOWN!" + val patterns = " *§r§6§l${displayName.uppercase()} DOWN!".toPattern() val location = reputationHelper.readLocationData(data) - miniBosses.add(CrimsonMiniBoss(displayName, displayItem, location, Pattern.compile(patterns))) + miniBosses.add(CrimsonMiniBoss(displayName, displayItem, location, patterns)) } //Config diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/HideMobNames.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/HideMobNames.kt index 2c0748962..5b2931c88 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/HideMobNames.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/HideMobNames.kt @@ -41,7 +41,7 @@ class HideMobNames { } private fun addMobToHide(bossName: String) { - patterns.add(Pattern.compile("§8\\[§7Lv(\\d+)§8] §c$bossName§r §[ae](.+)§f/§a(.+)§c❤")) + patterns.add("§8\\[§7Lv(\\d+)§8] §c$bossName§r §[ae](.+)§f/§a(.+)§c❤".toPattern()) } @SubscribeEvent(priority = EventPriority.HIGH) diff --git a/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt b/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt index 96b06377d..edb2bc2ac 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt @@ -14,7 +14,6 @@ import net.minecraftforge.event.world.WorldEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.TickEvent -import java.util.regex.Pattern class SummoningMobManager { @@ -26,14 +25,14 @@ class SummoningMobManager { private var searchMobs = false //§aYou have spawned your Tank Zombie §r§asoul! §r§d(249 Mana) - private val spawnPatter = Pattern.compile("§aYou have spawned your (.+) §r§asoul! §r§d\\((\\d+) Mana\\)") - private val despawnPatter = Pattern.compile("§cYou have despawned your (monster|monsters)!") + private val spawnPatter = "§aYou have spawned your (.+) §r§asoul! §r§d\\((\\d+) Mana\\)".toPattern() + private val despawnPatter = "§cYou have despawned your (monster|monsters)!".toPattern() //§a§ohannibal2's Tank Zombie§r §a160k§c❤ - private val healthPattern = Pattern.compile("§a§o(.+)'s (.+)§r §[ae]([\\dkm]+)§c❤") + private val healthPattern = "§a§o(.+)'s (.+)§r §[ae]([\\dkm]+)§c❤".toPattern() //§cThe Seraph recalled your 3 summoned allies! - private val seraphRecallPattern = Pattern.compile("§cThe Seraph recalled your (\\d) summoned allies!") + private val seraphRecallPattern = "§cThe Seraph recalled your (\\d) summoned allies!".toPattern() @SubscribeEvent fun onChatMessage(event: LorenzChatEvent) { |