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/garden | |
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/garden')
11 files changed, 24 insertions, 34 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 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 |