aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt34
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/CropAccessoryData.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/FriendAPI.kt35
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt14
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestonesCommunityFix.kt10
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ItemAddManager.kt7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt16
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt16
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/SkillExperience.kt19
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarCancelledBuyOrderClipboard.kt24
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarOrderHelper.kt18
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bingo/BingoAPI.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bingo/CompactBingoChat.kt27
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardReader.kt19
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bingo/card/nextstephelper/BingoNextStepHelper.kt29
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/chat/ArachneChatMessageHider.kt22
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/chat/PlayerDeathMessages.kt7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt14
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt38
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/combat/mobs/SpawnTimers.kt19
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaProfitTracker.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt15
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/diana/MythologicalCreatureTracker.kt39
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/jerry/frozentreasure/FrozenTreasure.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/jerry/frozentreasure/FrozenTreasureTracker.kt12
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/christmas/PresentWaypoints.kt18
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/winter/UniqueGiftCounter.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitTracker.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/SeaCreatureTracker.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishMessages.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt247
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneFix.kt13
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt22
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt23
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotAPI.kt11
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenWarpCommands.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/ToolTooltipTweaks.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterInventoryNumbers.kt14
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/contest/ContestBracket.kt7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt25
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestFFNeededDisplay.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestTimeNeeded.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/ArmorDropTracker.kt10
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerRngDropTracker.kt54
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt142
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/inventory/AnitaExtraFarmingFortune.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenInventoryNumbers.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/inventory/SkyMartCopperPrice.kt7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestFinder.kt14
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestSpawn.kt17
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorDropStatistics.kt38
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt30
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorTimer.kt10
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/NPCVisitorFix.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt1
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/HarpFeatures.kt17
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt40
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/ItemStars.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/StatsTuning.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/tiarelay/Relay.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt13
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/mining/powdertracker/PowderChestReward.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt21
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/CurrentPetDisplay.kt23
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/InGameDateDisplay.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/PatcherSendCoordinates.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/PlayerChatSymbols.kt13
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/ServerRestartTitle.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListReader.kt42
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListRenderer.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabStringType.kt7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/teleportpad/TeleportPadCompactName.kt18
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/teleportpad/TeleportPadInventoryNumber.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt48
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorTracker.kt28
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangFreezeCooldown.kt7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/area/stillgorechateau/RiftBloodEffigies.kt17
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminTracker.kt28
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/kloon/KloonHacking.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/CruxTalismanDisplay.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftTimer.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/RiftMotesOrb.kt11
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/ShowMotesNpcSellPrice.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerBossSpawnSoon.kt10
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt19
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/stranded/HighlightPlaceableNpcs.kt7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt28
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiIngameHook.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/TestCopyBestiaryValues.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/TestCopyRngMeterValues.kt13
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt16
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt44
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt26
102 files changed, 1294 insertions, 623 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index f41664ed3..56c25cf49 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -457,13 +457,13 @@ class SkyHanniMod {
loadModule(GardenAPI)
loadModule(GardenPlotAPI)
loadModule(DataWatcherAPI())
- loadModule(CollectionAPI())
+ loadModule(CollectionAPI)
loadModule(FarmingContestAPI)
loadModule(FriendAPI)
loadModule(PartyAPI)
loadModule(GuildAPI)
loadModule(SlayerAPI)
- loadModule(PurseAPI())
+ loadModule(PurseAPI)
loadModule(RiftAPI)
loadModule(SackAPI)
loadModule(BingoAPI)
@@ -617,7 +617,7 @@ class SkyHanniMod {
loadModule(EstimatedItemValue)
loadModule(EstimatedWardrobePrice())
loadModule(ComposterInventoryNumbers())
- loadModule(FarmingFortuneDisplay())
+ loadModule(FarmingFortuneDisplay)
loadModule(ToolTooltipTweaks())
loadModule(CropSpeedMeter())
loadModule(AshfangMinisNametagHider())
@@ -639,7 +639,7 @@ class SkyHanniMod {
loadModule(TrevorTracker)
loadModule(BingoCardTips())
loadModule(GardenVisitorDropStatistics)
- loadModule(CaptureFarmingGear())
+ loadModule(CaptureFarmingGear)
loadModule(SackDisplay)
loadModule(GardenStartLocation)
loadModule(PetCandyUsedDisplay())
diff --git a/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt b/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt
index ff744cecd..1e991605e 100644
--- a/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt
@@ -14,13 +14,25 @@ import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.matches
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-class CollectionAPI {
-
- // TODO USE SH-REPO
- private val counterPattern = ".* §e(?<amount>.*)§6/.*".toPattern()
- private val singleCounterPattern = "§7Total Collected: §e(?<amount>.*)".toPattern()
+object CollectionAPI {
+ private val patternGroup = RepoPattern.group("data.collection.api")
+ private val counterPattern by patternGroup.pattern(
+ "counter",
+ ".* §e(?<amount>.*)§6/.*"
+ )
+ private val singleCounterPattern by patternGroup.pattern(
+ "singlecounter",
+ "§7Total Collected: §e(?<amount>.*)"
+ )
+ private val collectionTier0Pattern by patternGroup.pattern(
+ "tierzero",
+ "§7Progress to .* I: .*"
+ )
+
+ val collectionValue = mutableMapOf<NEUInternalName, Long>()
@SubscribeEvent
fun onProfileJoin(event: ProfileJoinEvent) {
@@ -83,14 +95,6 @@ class CollectionAPI {
collectionValue.addOrPut(internalName, event.amount.toLong())
}
- companion object {
-
- // TODO USE SH-REPO
- val collectionValue = mutableMapOf<NEUInternalName, Long>()
- private val collectionTier0Pattern = "§7Progress to .* I: .*".toPattern()
-
- fun isCollectionTier0(lore: List<String>) = lore.any { collectionTier0Pattern.matches(it) }
-
- fun getCollectionCounter(internalName: NEUInternalName): Long? = collectionValue[internalName]
- }
+ fun isCollectionTier0(lore: List<String>) = lore.any { collectionTier0Pattern.matches(it) }
+ fun getCollectionCounter(internalName: NEUInternalName): Long? = collectionValue[internalName]
}
diff --git a/src/main/java/at/hannibal2/skyhanni/data/CropAccessoryData.kt b/src/main/java/at/hannibal2/skyhanni/data/CropAccessoryData.kt
index 9ea5742a1..b05cc0e56 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/CropAccessoryData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/CropAccessoryData.kt
@@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.NEUItems
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import com.google.gson.JsonElement
import net.minecraft.item.ItemStack
import net.minecraft.nbt.CompressedStreamTools
@@ -21,8 +22,11 @@ import java.util.Base64
class CropAccessoryData {
- // TODO USE SH-REPO
- private val accessoryBagNamePattern = "Accessory Bag \\((?<current>\\d)/(?<total>\\d)\\)".toPattern()
+ private val accessoryBagNamePattern by RepoPattern.pattern(
+ "data.accessory.bagname",
+ "Accessory Bag \\((?<current>\\d)/(?<total>\\d)\\)"
+ )
+
private var loadedAccessoryThisProfile = false
private var ticks = 0
private var accessoryInBag: CropAccessory? = null
diff --git a/src/main/java/at/hannibal2/skyhanni/data/FriendAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/FriendAPI.kt
index c9cfcc62f..f00b2bb4d 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/FriendAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/FriendAPI.kt
@@ -10,19 +10,37 @@ import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.StringUtils.cleanPlayerName
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.util.ChatStyle
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.util.UUID
object FriendAPI {
-
- // TODO USE SH-REPO
- private val removedFriendPattern =
- ".*\n§r§eYou removed §r(?<name>.*)§e from your friends list!§r§9§m\n.*".toPattern()
- private val addedFriendPattern = "§aYou are now friends with (?<name>.*)".toPattern()
- private val noBestFriendPattern = ".*\n§r(?<name>.*)§e is no longer a best friend!§r§9§m\n.*".toPattern()
- private val bestFriendPattern = ".*\n(?<name>.*)§a is now a best friend!§r§9§m\n.*".toPattern()
- private val readFriendListPattern = "/viewprofile (?<uuid>.*)".toPattern()
+ private val patternGroup = RepoPattern.group("data.friends")
+ private val removedFriendPattern by patternGroup.pattern(
+ "remove",
+ ".*\n§r§eYou removed §r(?<name>.*)§e from your friends list!§r§9§m\n.*"
+ )
+ private val addedFriendPattern by patternGroup.pattern(
+ "add",
+ "§aYou are now friends with (?<name>.*)"
+ )
+ private val noBestFriendPattern by patternGroup.pattern(
+ "removebest",
+ ".*\n§r(?<name>.*)§e is no longer a best friend!§r§9§m\n.*"
+ )
+ private val bestFriendPattern by patternGroup.pattern(
+ "addbest",
+ ".*\n(?<name>.*)§a is now a best friend!§r§9§m\n.*"
+ )
+ private val rawNamePattern by patternGroup.pattern(
+ "rawname",
+ "\\n§eClick to view §.(?<name>.*)§e's profile"
+ )
+ private val readFriendListPattern by patternGroup.pattern(
+ "readfriends",
+ "/viewprofile (?<uuid>.*)"
+ )
private val tempFriends = mutableListOf<Friend>()
@@ -130,7 +148,6 @@ object FriendAPI {
private fun readName(chatStyle: ChatStyle): String? {
for (component in chatStyle.chatHoverEvent.value.siblings) {
val rawName = component.unformattedText
- val rawNamePattern = "\\n§eClick to view §.(?<name>.*)§e's profile".toPattern()
rawNamePattern.matchMatcher(rawName) {
return group("name")
}
diff --git a/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt b/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt
index dfa275cb7..5f61f0330 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt
@@ -9,14 +9,20 @@ import at.hannibal2.skyhanni.features.garden.GardenAPI
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.item.ItemStack
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
object GardenCropMilestones {
-
- // TODO USE SH-REPO
- private val cropPattern = "§7Harvest §f(?<name>.*) §7on .*".toPattern()
- val totalPattern = "§7Total: §a(?<name>.*)".toPattern()
+ private val patternGroup = RepoPattern.group("data.garden.milestone")
+ private val cropPattern by patternGroup.pattern(
+ "crop",
+ "§7Harvest §f(?<name>.*) §7on .*"
+ )
+ val totalPattern by patternGroup.pattern(
+ "total",
+ "§7Total: §a(?<name>.*)"
+ )
fun getCropTypeByLore(itemStack: ItemStack): CropType? {
for (line in itemStack.getLore()) {
diff --git a/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestonesCommunityFix.kt b/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestonesCommunityFix.kt
index 950f226f1..e38e3d075 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestonesCommunityFix.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestonesCommunityFix.kt
@@ -19,13 +19,17 @@ import at.hannibal2.skyhanni.utils.OSUtils
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.matches
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import kotlinx.coroutines.launch
import net.minecraft.item.ItemStack
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
object GardenCropMilestonesCommunityFix {
+ private val amountPattern by RepoPattern.pattern(
+ "data.garden.milestonefix.amount",
+ ".*§e(?<having>.*)§6/§e(?<max>.*)"
+ )
- private val pattern = ".*§e(?<having>.*)§6/§e(?<max>.*)".toPattern()
private var showWrongData = false
private var showWhenAllCorrect = false
@@ -92,7 +96,7 @@ object GardenCropMilestonesCommunityFix {
crop
) - GardenCropMilestones.getCropsForTier(realTier, crop)
// debug("guessNextMax: ${guessNextMax.addSeparators()}")
- val nextMax = pattern.matchMatcher(next) {
+ val nextMax = amountPattern.matchMatcher(next) {
group("max").formatNumber()
} ?: return
// debug("nextMax real: ${nextMax.addSeparators()}")
@@ -103,7 +107,7 @@ object GardenCropMilestonesCommunityFix {
val guessTotalMax = GardenCropMilestones.getCropsForTier(46, crop)
// println("guessTotalMax: ${guessTotalMax.addSeparators()}")
- val totalMax = pattern.matchMatcher(total) {
+ val totalMax = amountPattern.matchMatcher(total) {
group("max").formatNumber()
} ?: return
// println("totalMax real: ${totalMax.addSeparators()}")
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ItemAddManager.kt b/src/main/java/at/hannibal2/skyhanni/data/ItemAddManager.kt
index 3d4b8f067..601fafb12 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/ItemAddManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/ItemAddManager.kt
@@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.StringUtils.matches
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.Duration.Companion.seconds
@@ -25,8 +26,10 @@ class ItemAddManager {
private val ARCHFIEND_DICE = "ARCHFIEND_DICE".asInternalName()
private val HIGH_CLASS_ARCHFIEND_DICE = "HIGH_CLASS_ARCHFIEND_DICE".asInternalName()
- private val diceRollChatPattern =
- "§eYour §r§(5|6High Class )Archfiend Dice §r§erolled a §r§.(?<number>.)§r§e! Bonus: §r§.(?<hearts>.*)❤".toPattern()
+ private val diceRollChatPattern by RepoPattern.pattern(
+ "data.itemmanager.diceroll",
+ "§eYour §r§(5|6High Class )Archfiend Dice §r§erolled a §r§.(?<number>.)§r§e! Bonus: §r§.(?<hearts>.*)❤"
+ )
private var inSackInventory = false
private var lastSackInventoryLeave = SimpleTimeMark.farPast()
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt b/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt
index e4b54115c..08894d4a3 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt
@@ -14,6 +14,7 @@ import at.hannibal2.skyhanni.events.TabListUpdateEvent
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -26,8 +27,16 @@ object ProfileStorageData {
private var nextProfile: String? = null
- // TODO USE SH-REPO
- private val profileSwitchPattern = "§7Switching to profile (?<name>.*)\\.\\.\\.".toPattern()
+ private val patternGroup = RepoPattern.group("data.profile")
+ private val profileSwitchPattern by patternGroup.pattern(
+ "switch",
+ "§7Switching to profile (?<name>.*)\\.\\.\\."
+ )
+ private val profileNamePattern by patternGroup.pattern(
+ "name",
+ "§e§lProfile: §r§a(?<name>.*)"
+ )
+
private var sackPlayers: SackData.PlayerSpecific? = null
var sackProfiles: SackData.ProfileSpecific? = null
@@ -85,8 +94,7 @@ object ProfileStorageData {
val playerSpecific = playerSpecific ?: return
val sackPlayers = sackPlayers ?: return
for (line in event.tabList) {
- val pattern = "§e§lProfile: §r§a(?<name>.*)".toPattern()
- pattern.matchMatcher(line) {
+ profileNamePattern.matchMatcher(line) {
val profileName = group("name").lowercase()
loadProfileSpecific(playerSpecific, sackPlayers, profileName)
nextProfile = null
diff --git a/src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt
index e5f226945..184d41567 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt
@@ -7,13 +7,21 @@ import at.hannibal2.skyhanni.events.PurseChangeEvent
import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber
import at.hannibal2.skyhanni.utils.NumberUtil.milion
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.client.Minecraft
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-class PurseAPI {
+object PurseAPI {
+ private val patternGroup = RepoPattern.group("data.purse")
+ private val coinsPattern by patternGroup.pattern(
+ "coins",
+ "(Piggy|Purse): §6(?<coins>[\\d,]+).*"
+ )
+ val piggyPattern by patternGroup.pattern(
+ "piggy",
+ "Piggy: (?<coins>.*)"
+ )
- // TODO USE SH-REPO
- private val pattern = "(Piggy|Purse): §6(?<coins>[\\d,]*).*".toPattern()
private var currentPurse = 0.0
private var inventoryCloseTime = 0L
@@ -26,7 +34,7 @@ class PurseAPI {
fun onTick(event: LorenzTickEvent) {
for (line in ScoreboardData.sidebarLinesFormatted) {
- val newPurse = pattern.matchMatcher(line) {
+ val newPurse = coinsPattern.matchMatcher(line) {
group("coins").formatNumber().toDouble()
} ?: continue
val diff = newPurse - currentPurse
diff --git a/src/main/java/at/hannibal2/skyhanni/data/SkillExperience.kt b/src/main/java/at/hannibal2/skyhanni/data/SkillExperience.kt
index f7915a94c..93fb6e14e 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/SkillExperience.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/SkillExperience.kt
@@ -11,14 +11,23 @@ import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber
import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal
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
class SkillExperience {
-
- // TODO USE SH-REPO
- private val actionBarPattern = ".*§3\\+.* (?<skill>.*) \\((?<overflow>.*)/(?<needed>.*)\\).*".toPattern()
- private val inventoryPattern = ".* §e(?<number>.*)§6/.*".toPattern()
- private val actionBarLowLevelPattern = ".*§3+(?<add>.+) (?<skill>.*) \\((?<percentage>.*)%\\).*".toPattern()
+ private val patternGroup = RepoPattern.group("data.skill")
+ private val actionBarPattern by patternGroup.pattern(
+ "actionbar",
+ ".*§3\\+.* (?<skill>.*) \\((?<overflow>.*)/(?<needed>.*)\\).*"
+ )
+ private val inventoryPattern by patternGroup.pattern(
+ "inventory",
+ ".* §e(?<number>.*)§6/.*"
+ )
+ private val actionBarLowLevelPattern by patternGroup.pattern(
+ "actionbarlow",
+ ".*§3+(?<add>.+) (?<skill>.*) \\((?<percentage>.*)%\\).*"
+ )
@SubscribeEvent
fun onProfileJoin(event: ProfileJoinEvent) {
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 b0e96ca1f..3c5403309 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarCancelledBuyOrderClipboard.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarCancelledBuyOrderClipboard.kt
@@ -8,15 +8,22 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.OSUtils
+import at.hannibal2.skyhanni.utils.StringUtils.findMatcher
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-import java.util.regex.Pattern
class BazaarCancelledBuyOrderClipboard {
- private val patternLastAmount = Pattern.compile("§a(?<amount>.*)§7x")
- private val patternCancelledMessage =
- "§6\\[Bazaar] §r§7§r§cCancelled! §r§7Refunded §r§6(?<coins>.*) coins §r§7from cancelling Buy Order!".toPattern()
+ private val patternGroup = RepoPattern.group("bazaar.cancelledorder")
+ private val lastAmountPattern by patternGroup.pattern(
+ "lastamount",
+ "§a(?<amount>.*)§7x"
+ )
+ private val cancelledMessagePattern by patternGroup.pattern(
+ "cancelledmessage",
+ "§6\\[Bazaar] §r§7§r§cCancelled! §r§7Refunded §r§6(?<coins>.*) coins §r§7from cancelling Buy Order!"
+ )
private var latestAmount: String? = null
@@ -29,9 +36,8 @@ class BazaarCancelledBuyOrderClipboard {
if (!name.contains("Cancel Order")) return
for (line in stack.getLore()) {
- val matcher = patternLastAmount.matcher(line)
- if (matcher.find()) {
- latestAmount = matcher.group("amount")
+ lastAmountPattern.findMatcher(line) {
+ latestAmount = group("amount")
}
}
}
@@ -40,8 +46,8 @@ class BazaarCancelledBuyOrderClipboard {
fun onChat(event: LorenzChatEvent) {
if (!isEnabled()) return
- patternCancelledMessage.matchMatcher(event.message) {
- event.blockedReason = "bazaar cancelled buy order clipbaord"
+ cancelledMessagePattern.matchMatcher(event.message) {
+ event.blockedReason = "bazaar cancelled buy order clipboard"
val coins = group("coins")
ChatUtils.chat("Bazaar buy order cancelled. $latestAmount saved to clipboard. ($coins coins)")
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarOrderHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarOrderHelper.kt
index da828ef31..6a42fe214 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarOrderHelper.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarOrderHelper.kt
@@ -10,16 +10,26 @@ import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RenderUtils.highlight
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.client.gui.inventory.GuiChest
import net.minecraft.inventory.ContainerChest
import net.minecraft.inventory.Slot
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class BazaarOrderHelper {
-
- private val bazaarItemNamePattern = "§.§l(?<type>BUY|SELL) (?<name>.*)".toPattern()
- private val filledPattern = "§7Filled: §[a6].*§7/.* §a§l100%!".toPattern()
- private val pricePattern = "§7Price per unit: §6(?<number>.*) coins".toPattern()
+ private val patternGroup = RepoPattern.group("bazaar.orderhelper")
+ private val bazaarItemNamePattern by patternGroup.pattern(
+ "itemname",
+ "§.§l(?<type>BUY|SELL) (?<name>.*)"
+ )
+ private val filledPattern by patternGroup.pattern(
+ "filled",
+ "§7Filled: §[a6].*§7/.* §a§l100%!"
+ )
+ private val pricePattern by patternGroup.pattern(
+ "price",
+ "§7Price per unit: §6(?<number>.*) coins"
+ )
companion object {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoAPI.kt
index a86a05c60..037233772 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoAPI.kt
@@ -27,7 +27,10 @@ object BingoAPI {
val communityGoals get() = bingoGoals.values.filter { it.type == GoalType.COMMUNITY }
var lastBingoCardOpenTime = SimpleTimeMark.farPast()
- private val detectionPattern by RepoPattern.pattern("bingo.detection.scoreboard", " §.Ⓑ §.Bingo")
+ private val detectionPattern by RepoPattern.pattern(
+ "bingo.detection.scoreboard",
+ " §.Ⓑ §.Bingo"
+ )
@SubscribeEvent
fun onRepoReload(event: RepositoryReloadEvent) {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/CompactBingoChat.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/CompactBingoChat.kt
index 7c0e74cae..814de64ef 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bingo/CompactBingoChat.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/CompactBingoChat.kt
@@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.utils.ChatUtils
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.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class CompactBingoChat {
@@ -16,20 +17,29 @@ class CompactBingoChat {
private var inSkyBlockLevelUp = false
private var inCollectionLevelUp = false
private var collectionLevelUpLastLine: String? = null
- private var newArea = 0// 0 = nothing, 1 = after first message, 2 = after second message
- private val healthPattern = " {3}§r§7§8\\+§a.* §c❤ Health".toPattern()
- private val strengthPattern = " {3}§r§7§8\\+§a. §c❁ Strength".toPattern()
+ private var newArea = 0 // 0 = nothing, 1 = after first message, 2 = after second message
+
+ private val patternGroup = RepoPattern.group("bingo.compactchat")
+ private val healthPattern by patternGroup.pattern(
+ "health",
+ " {3}§r§7§8\\+§a.* §c❤ Health"
+ )
+ private val strengthPattern by patternGroup.pattern(
+ "strength",
+ " {3}§r§7§8\\+§a. §c❁ Strength"
+ )
+ private val borderPattern by patternGroup.pattern(
+ "border",
+ "§[e3]§l▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬"
+ )
- // TODO USE SH-REPO
@SubscribeEvent
fun onChat(event: LorenzChatEvent) {
if (!config.enabled) return
if (!LorenzUtils.isBingoProfile && !config.outsideBingo) return
val message = event.message
- if (message == "§3§l▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬" ||
- message == "§e§l▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬"
- ) {
+ borderPattern.matchMatcher(message) {
inSkillLevelUp = false
inSkyBlockLevelUp = false
inCollectionLevelUp = false
@@ -45,6 +55,7 @@ class CompactBingoChat {
if (onNewAreaDiscovered(message)) event.blockedReason = "compact_new_area_discovered"
}
+ // TODO USE SH-REPO
private fun onSkillLevelUp(message: String): Boolean {
if (message.startsWith(" §r§b§lSKILL LEVEL UP ")) {
inSkillLevelUp = true
@@ -74,7 +85,7 @@ class CompactBingoChat {
return true
}
- // No Bazaar and Community Shopin bingo
+ // No Bazaar and Community Shop in bingo
if (message == " §r§7§6Access to Bazaar") return true
if (message == " §r§7§bAccess to Community Shop") return true
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 930ea6883..dbdf73535 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt
@@ -21,6 +21,7 @@ import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import com.google.gson.JsonArray
import com.google.gson.JsonObject
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import io.github.moulberry.notenoughupdates.recipes.CraftingRecipe
import net.minecraft.client.Minecraft
import net.minecraft.item.ItemStack
@@ -31,8 +32,11 @@ class MinionCraftHelper {
private val config get() = SkyHanniMod.feature.event.bingo
- // TODO USE SH-REPO
- private var minionNamePattern = "(?<name>.*) Minion (?<number>.*)".toPattern()
+ private val minionNamePattern by RepoPattern.pattern(
+ "bingo.minion.name",
+ "(?<name>.*) Minion (?<number>.*)"
+ )
+
private var display = emptyList<String>()
private var hasMinionInInventory = false
private var hasItemsForMinion = false
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardReader.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardReader.kt
index be27e25a2..c0606ad54 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardReader.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardReader.kt
@@ -25,12 +25,19 @@ import kotlin.time.Duration
class BingoCardReader {
private val config get() = SkyHanniMod.feature.event.bingo.bingoCard
-
- private val percentagePattern by RepoPattern.pattern("bingo.card.percentage", " {2}§8Top §.(?<percentage>.*)%")
-
- // TODO USE SH-REPO
- private val goalCompletePattern = "§6§lBINGO GOAL COMPLETE! §r§e(?<name>.*)".toPattern()
- private val personalHiddenGoalPattern = ".*§7§eThe next hint will unlock in (?<time>.*)".toPattern()
+ private val patternGroup = RepoPattern.group("bingo.card")
+ private val percentagePattern by patternGroup.pattern(
+ "percentage",
+ " {2}§8Top §.(?<percentage>.*)%"
+ )
+ private val goalCompletePattern by patternGroup.pattern(
+ "goalcomplete",
+ "§6§lBINGO GOAL COMPLETE! §r§e(?<name>.*)"
+ )
+ private val personalHiddenGoalPattern by patternGroup.pattern(
+ "hiddengoal",
+ ".*§7§eThe next hint will unlock in (?<time>.*)"
+ )
@SubscribeEvent
fun onInventoryOpen(event: InventoryUpdatedEvent) {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/nextstephelper/BingoNextStepHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/nextstephelper/BingoNextStepHelper.kt
index 6987edb82..be4a8c7a4 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/nextstephelper/BingoNextStepHelper.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/nextstephelper/BingoNextStepHelper.kt
@@ -24,6 +24,7 @@ import at.hannibal2.skyhanni.utils.ItemUtils.name
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.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class BingoNextStepHelper {
@@ -31,15 +32,31 @@ class BingoNextStepHelper {
private val config get() = SkyHanniMod.feature.event.bingo.bingoCard
private var dirty = true
- // TODO USE SH-REPO
- private val crystalObtainedPattern = " *§r§e(?<crystalName>Topaz|Sapphire|Jade|Amethyst|Amber) Crystal".toPattern()
+ private val patternGroup = RepoPattern.group("bingo.steps")
+ private val crystalObtainedPattern by patternGroup.pattern(
+ "crystal.obtained",
+ " *§r§e(?<crystalName>Topaz|Sapphire|Jade|Amethyst|Amber) Crystal"
+ )
+ private val collectionPattern by patternGroup.pattern(
+ "collection",
+ "Reach (?<amount>[0-9]+(?:,\\d+)*) (?<name>.*) Collection\\."
+ )
+ private val crystalPattern by patternGroup.pattern(
+ "crystal.obtain",
+ "Obtain a (?<name>\\w+) Crystal in the Crystal Hollows\\."
+ )
+ private val skillPattern by patternGroup.pattern(
+ "skill",
+ "Obtain level (?<level>.*) in the (?<skill>.*) Skill."
+ )
+ private val crystalFoundPattern by patternGroup.pattern(
+ "crystal.found",
+ " *§r§5§l✦ CRYSTAL FOUND §r§7\\(.§r§7/5§r§7\\)"
+ )
+
private val itemIslandRequired = mutableMapOf<String, IslandVisitStep>()
private val itemPreconditions = mutableMapOf<String, NextStep>()
private val islands = mutableMapOf<IslandType, IslandVisitStep>()
- private val collectionPattern = "Reach (?<amount>[0-9]+(?:,\\d+)*) (?<name>.*) Collection\\.".toPattern()
- private val crystalPattern = "Obtain a (?<name>\\w+) Crystal in the Crystal Hollows\\.".toPattern()
- private val skillPattern = "Obtain level (?<level>.*) in the (?<skill>.*) Skill.".toPattern()
- private val crystalFoundPattern = " *§r§5§l✦ CRYSTAL FOUND §r§7\\(.§r§7/5§r§7\\)".toPattern()
private val rhysTaskName = "30x Enchanted Minerals (Redstone, Lapis Lazuli, Coal) (for Rhys)"
companion object {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/ArachneChatMessageHider.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/ArachneChatMessageHider.kt
index 54dc6bed0..57a9a5f9e 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/chat/ArachneChatMessageHider.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/chat/ArachneChatMessageHider.kt
@@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class ArachneChatMessageHider {
@@ -12,9 +13,19 @@ class ArachneChatMessageHider {
private val config get() = SkyHanniMod.feature.chat
private var hideArachneDeadMessage = false
- // TODO USE SH-REPO
- private val arachneCallingPattern = "§4☄ §r.* §r§eplaced an §r§9Arachne's Calling§r§e!.*".toPattern()
- private val arachneCrystalPattern = "§4☄ §r.* §r§eplaced an Arachne Crystal! Something is awakening!".toPattern()
+ private val patternGroup = RepoPattern.group("chat.arachne")
+ private val arachneCallingPattern by patternGroup.pattern(
+ "calling",
+ "§4☄ §r.* §r§eplaced an §r§9Arachne's Calling§r§e!.*"
+ )
+ private val arachneCrystalPattern by patternGroup.pattern(
+ "crystal",
+ "§4☄ §r.* §r§eplaced an Arachne Crystal! Something is awakening!"
+ )
+ private val arachneSpawnPattern by patternGroup.pattern(
+ "spawn",
+ "§c\\[BOSS] Arachne§r§f: (?:The Era of Spiders begins now\\.|Ahhhh\\.\\.\\.A Calling\\.\\.\\.)"
+ )
@SubscribeEvent
fun onChat(event: LorenzChatEvent) {
@@ -36,8 +47,9 @@ class ArachneChatMessageHider {
return true
}
- if (message == "§c[BOSS] Arachne§r§f: Ahhhh...A Calling...") return true
- if (message == "§c[BOSS] Arachne§r§f: The Era of Spiders begins now.") return true
+ arachneSpawnPattern.matchMatcher(message) {
+ return true
+ }
if (message == "§a§l▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬") {
hideArachneDeadMessage = !hideArachneDeadMessage
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 3f0c4b700..5516cbe77 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerDeathMessages.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerDeathMessages.kt
@@ -11,6 +11,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.client.entity.EntityOtherPlayerMP
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -18,9 +19,11 @@ class PlayerDeathMessages {
private val lastTimePlayerSeen = mutableMapOf<String, Long>()
- // TODO USE SH-REPO
//§c ☠ §r§7§r§bZeroHazel§r§7 was killed by §r§8§lAshfang§r§7§r§7.
- private val deathMessagePattern = "§c ☠ §r§7§r§.(?<name>.+)§r§7 (?<reason>.+)".toPattern()
+ private val deathMessagePattern by RepoPattern.pattern(
+ "chat.player.death",
+ "§c ☠ §r§7§r§.(?<name>.+)§r§7 (?<reason>.+)"
+ )
@SubscribeEvent
fun onTick(event: LorenzTickEvent) {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt
index a5b0cd386..bd1d58894 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt
@@ -27,18 +27,28 @@ import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.renderables.Renderable
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.item.ItemStack
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
object BestiaryData {
private val config get() = SkyHanniMod.feature.combat.bestiary
+
+ private val patternGroup = RepoPattern.group("combat.bestiary.data")
+ private val progressPattern by patternGroup.pattern(
+ "progress",
+ "(?<current>[0-9kKmMbB,.]+)/(?<needed>[0-9kKmMbB,.]+\$)"
+ )
+ private val titlePattern by patternGroup.pattern(
+ "title",
+ "^(?:\\(\\d+/\\d+\\) )?(Bestiary|.+) ➜ (.+)\$"
+ )
+
private var display = emptyList<List<Any>>()
private val mobList = mutableListOf<BestiaryMob>()
private val stackList = mutableMapOf<Int, ItemStack>()
private val catList = mutableListOf<Category>()
- private val progressPattern = "(?<current>[0-9kKmMbB,.]+)/(?<needed>[0-9kKmMbB,.]+$)".toPattern()
- private val titlePattern = "^(?:\\(\\d+/\\d+\\) )?(Bestiary|.+) ➜ (.+)$".toPattern()
private var inInventory = false
private var isCategory = false
private var overallProgressEnabled = false
diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt
index 5c1e0976e..0364bda1a 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt
@@ -52,6 +52,7 @@ import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.renderables.Renderable
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import io.github.moulberry.notenoughupdates.util.Utils
import io.github.moulberry.notenoughupdates.util.XPInformation
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -68,16 +69,33 @@ object GhostCounter {
private var display = emptyList<List<Any>>()
var ghostCounterV3File =
File("." + File.separator + "config" + File.separator + "ChatTriggers" + File.separator + "modules" + File.separator + "GhostCounterV3" + File.separator + ".persistantData.json")
- private val skillXPPattern = "[+](?<gained>[0-9,.]+) \\((?<current>[0-9,.]+)(?:/(?<total>[0-9,.]+))?\\)".toPattern()
- private val combatSectionPattern =
- ".*[+](?<gained>[0-9,.]+) (?<skillName>[A-Za-z]+) \\((?<progress>(?<current>[0-9.,]+)/(?<total>[0-9.,]+)|(?<percent>[0-9.]+)%)\\).*".toPattern()
- private val killComboExpiredPattern =
- "§cYour Kill Combo has expired! You reached a (?<combo>.*) Kill Combo!".toPattern()
- private val ghostXPPattern =
- "(?<current>\\d+(?:\\.\\d+)?(?:,\\d+)?[kK]?)/(?<total>\\d+(?:\\.\\d+)?(?:,\\d+)?[kKmM]?)".toPattern()
- private val bestiaryPattern =
- ".*(?:§\\d|§\\w)+BESTIARY (?:§\\d|§\\w)+Ghost (?:§\\d|§\\w)(?<previousLevel>\\d+)➜(?:§\\d|§\\w)(?<nextLevel>\\d+).*".toPattern() // &3&lBESTIARY &b&lGhost &89➜&b10
- private val skillLevelPattern = ".*§e§lSkills: §r§a(?<skillName>.*) (?<skillLevel>\\d+).*".toPattern()
+
+ private val patternGroup = RepoPattern.group("combat.ghostcounter")
+ private val skillXPPattern by patternGroup.pattern(
+ "skillxp",
+ "[+](?<gained>[0-9,.]+) \\((?<current>[0-9,.]+)(?:/(?<total>[0-9,.]+))?\\)"
+ )
+ private val combatSectionPattern by patternGroup.pattern(
+ "combatsection",
+ ".*[+](?<gained>[0-9,.]+) (?<skillName>[A-Za-z]+) \\((?<progress>(?<current>[0-9.,]+)/(?<total>[0-9.,]+)|(?<percent>[0-9.]+)%)\\).*"
+ )
+ private val killComboExpiredPattern by patternGroup.pattern(
+ "killcomboexpired",
+ "§cYour Kill Combo has expired! You reached a (?<combo>.*) Kill Combo!"
+ )
+ private val ghostXPPattern by patternGroup.pattern(
+ "ghostxp",
+ "(?<current>\\d+(?:\\.\\d+)?(?:,\\d+)?[kK]?)/(?<total>\\d+(?:\\.\\d+)?(?:,\\d+)?[kKmM]?)"
+ )
+ private val bestiaryPattern by patternGroup.pattern(
+ "bestiary",
+ ".*(?:§\\d|§\\w)+BESTIARY (?:§\\d|§\\w)+Ghost (?:§\\d|§\\w)(?<previousLevel>\\d+)➜(?:§\\d|§\\w)(?<nextLevel>\\d+).*"
+ )
+ private val skillLevelPattern by patternGroup.pattern(
+ "skilllevel",
+ ".*§e§lSkills: §r§a(?<skillName>.*) (?<skillLevel>\\d+).*"
+ )
+
private val format = NumberFormat.getInstance()
private var percent: Float = 0.0f
private var totalSkillXp = 0
diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/SpawnTimers.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/SpawnTimers.kt
index 08c8ddf31..f92e8dccd 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/SpawnTimers.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/SpawnTimers.kt
@@ -14,6 +14,7 @@ import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.StringUtils.matches
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.TimeUtils.format
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import at.hannibal2.skyhanni.utils.toLorenzVec
import net.minecraft.network.play.server.S2APacketParticles
import net.minecraft.util.EnumParticleTypes
@@ -25,12 +26,18 @@ class SpawnTimers {
private val config get() = SkyHanniMod.feature.combat.mobs
+ private val patternGroup = RepoPattern.group("combat.mobs.spawntime.arachne")
+ private val arachneFragmentPattern by patternGroup.pattern(
+ "fragment",
+ "^☄ [a-z0-9_]{2,22} placed an arachne's calling! something is awakening! \\(4/4\\)\$"
+ )
+ private val arachneCrystalPattern by patternGroup.pattern(
+ "crystal",
+ "^☄ [a-z0-9_]{2,22} placed an arachne crystal! something is awakening!$"
+ )
+
private val arachneAltarLocation = LorenzVec(-283f, 51f, -179f)
private var arachneSpawnTime = SimpleTimeMark.farPast()
- private val arachneFragmentMessage =
- "^☄ [a-z0-9_]{2,22} placed an arachne's calling! something is awakening! \\(4/4\\)\$".toPattern()
- private val arachneCrystalMessage =
- "^☄ [a-z0-9_]{2,22} placed an arachne crystal! something is awakening!$".toPattern()
private var saveNextTickParticles = false
private var particleCounter = 0
private var tickTime: Long = 0
@@ -60,8 +67,8 @@ class SpawnTimers {
if (!isEnabled()) return
val message = event.message.removeColor().lowercase()
- if (arachneFragmentMessage.matches(message) || arachneCrystalMessage.matches(message)) {
- if (arachneCrystalMessage.matches(message)) {
+ if (arachneFragmentPattern.matches(message) || arachneCrystalPattern.matches(message)) {
+ if (arachneCrystalPattern.matches(message)) {
saveNextTickParticles = true
searchTime = System.currentTimeMillis()
particleCounter = 0
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaProfitTracker.kt
index a41ee2689..7724d4c5d 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaProfitTracker.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaProfitTracker.kt
@@ -28,12 +28,13 @@ object DianaProfitTracker {
private val config get() = SkyHanniMod.feature.event.diana.dianaProfitTracker
private var allowedDrops = listOf<NEUInternalName>()
- private val chatDugOutPattern by RepoPattern.pattern(
- "diana.chat.burrow.dug",
+ private val patternGroup = RepoPattern.group("diana.chat")
+ private val chatDugOutPattern by patternGroup.pattern(
+ "burrow.dug",
"(§eYou dug out a Griffin Burrow!|§eYou finished the Griffin burrow chain!) .*"
)
- private val chatDugOutCoinsPattern by RepoPattern.pattern(
- "diana.chat.coins",
+ private val chatDugOutCoinsPattern by patternGroup.pattern(
+ "coins",
"§6§lWow! §r§eYou dug out §r§6(?<coins>.*) coins§r§e!"
)
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt
index 9276823fe..66d4f2b85 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt
@@ -20,6 +20,7 @@ import at.hannibal2.skyhanni.utils.SoundUtils
import at.hannibal2.skyhanni.utils.StringUtils.cleanPlayerName
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.getLorenzVec
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.client.Minecraft
import net.minecraft.client.entity.EntityOtherPlayerMP
import net.minecraft.network.play.server.S02PacketChat
@@ -32,10 +33,16 @@ object InquisitorWaypointShare {
private val config get() = SkyHanniMod.feature.event.diana.inquisitorSharing
- // TODO USE SH-REPO
- private val partyPattern =
- "§9Party §8> (?<playerName>.*)§f: §rx: (?<x>-?[0-9]{1,4}), y: (?<y>-?[0-9]{1,4}), z: (?<z>-?[0-9]{1,4})\\b".toPattern()
- private val diedPattern = "§9Party §8> (?<playerName>.*)§f: §rInquisitor dead!".toPattern()
+ private val patternGroup = RepoPattern.group("diana.waypoints")
+ private val partyPattern by patternGroup.pattern(
+ "party",
+ "§9Party §8> (?<playerName>.*)§f: §rx: (?<x>-?[0-9]{1,4}), y: (?<y>-?[0-9]{1,4}), z: (?<z>-?[0-9]{1,4})\\b"
+ )
+ private val diedPattern by patternGroup.pattern(
+ "died",
+ "§9Party §8> (?<playerName>.*)§f: §rInquisitor dead!"
+ )
+
private var time = 0L
private var testTime = 0L
private var lastInquisitorMessage = ""
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/MythologicalCreatureTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/MythologicalCreatureTracker.kt
index dbcc1574e..001a96c4a 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/MythologicalCreatureTracker.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/MythologicalCreatureTracker.kt
@@ -21,23 +21,36 @@ import java.util.regex.Pattern
object MythologicalCreatureTracker {
- private val group = RepoPattern.group("event.diana.mythological.tracker")
-
- private val minotaurPattern by group.pattern("minotaur", ".* §r§eYou dug out a §r§2Minotaur§r§e!")
- private val gaiaConstructPattern by group.pattern("gaiaconstruct", ".* §r§eYou dug out a §r§2Gaia Construct§r§e!")
- private val minosChampionPattern by group.pattern("minoschampion", ".* §r§eYou dug out a §r§2Minos Champion§r§e!")
- private val siameseLynxesPattern by group.pattern("siameselynxes", ".* §r§eYou dug out §r§2Siamese Lynxes§r§e!")
- private val minosHunterPattern by group.pattern("minoshunter", ".* §r§eYou dug out a §r§2Minos Hunter§r§e!")
- private val minosInquisitorPattern by group.pattern(
+ private val config get() = SkyHanniMod.feature.event.diana.mythologicalMobtracker
+
+ private val patternGroup = RepoPattern.group("event.diana.mythological.tracker")
+ private val minotaurPattern by patternGroup.pattern(
+ "minotaur",
+ ".* §r§eYou dug out a §r§2Minotaur§r§e!"
+ )
+ private val gaiaConstructPattern by patternGroup.pattern(
+ "gaiaconstruct",
+ ".* §r§eYou dug out a §r§2Gaia Construct§r§e!"
+ )
+ private val minosChampionPattern by patternGroup.pattern(
+ "minoschampion",
+ ".* §r§eYou dug out a §r§2Minos Champion§r§e!"
+ )
+ private val siameseLynxesPattern by patternGroup.pattern(
+ "siameselynxes",
+ ".* §r§eYou dug out §r§2Siamese Lynxes§r§e!"
+ )
+ private val minosHunterPattern by patternGroup.pattern(
+ "minoshunter",
+ ".* §r§eYou dug out a §r§2Minos Hunter§r§e!"
+ )
+ private val minosInquisitorPattern by patternGroup.pattern(
"minosinquisitor",
".* §r§eYou dug out a §r§2Minos Inquisitor§r§e!"
)
- private val config get() = SkyHanniMod.feature.event.diana.mythologicalMobtracker
-
- private val tracker =
- SkyHanniTracker("Mythological Creature Tracker", { Data() }, { it.diana.mythologicalMobTracker })
- { drawDisplay(it) }
+ private val tracker = SkyHanniTracker("Mythological Creature Tracker", { Data() }, { it.diana.mythologicalMobTracker })
+ { drawDisplay(it) }
class Data : TrackerData() {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/jerry/frozentreasure/FrozenTreasure.kt b/src/main/java/at/hannibal2/skyhanni/features/event/jerry/frozentreasure/FrozenTreasure.kt
index 219a22285..2511b2ee1 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/jerry/frozentreasure/FrozenTreasure.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/jerry/frozentreasure/FrozenTreasure.kt
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.features.event.jerry.frozentreasure
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
enum class FrozenTreasure(
val internalName: String,
@@ -23,5 +24,11 @@ enum class FrozenTreasure(
EINARY_RED_HOODIE("FROZEN_BAIT", "§cEinary's Red Hoodie", 1),
;
- val pattern by lazy { "FROZEN TREASURE! You found ${displayName.removeColor()}!".toPattern() }
+ val chatPattern by RepoPattern.pattern(
+ "event.jerry.frozentreasure.item." + this.patternName(),
+ patternText()
+ )
+
+ private fun patternName() = name.lowercase().replace("_", "")
+ private fun patternText() = "FROZEN TREASURE! You found ${displayName.removeColor()}!"
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/jerry/frozentreasure/FrozenTreasureTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/event/jerry/frozentreasure/FrozenTreasureTracker.kt
index 7b3f236f0..f335b882c 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/jerry/frozentreasure/FrozenTreasureTracker.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/jerry/frozentreasure/FrozenTreasureTracker.kt
@@ -18,6 +18,7 @@ import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.matches
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
+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.annotations.Expose
@@ -27,16 +28,23 @@ import kotlin.concurrent.fixedRateTimer
object FrozenTreasureTracker {
private val config get() = SkyHanniMod.feature.event.winter.frozenTreasureTracker
+
+ private val compactPattern by RepoPattern.pattern(
+ "event.jerry.frozentreasure.compact",
+ "COMPACT! You found an Enchanted Ice!"
+ )
+
private var estimatedIce = 0L
private var lastEstimatedIce = 0L
private var icePerSecond = mutableListOf<Long>()
private var icePerHour = 0
private var stoppedChecks = 0
- private var compactPattern = "COMPACT! You found an Enchanted Ice!".toPattern()
private val tracker = SkyHanniTracker("Frozen Treasure Tracker", { Data() }, { it.frozenTreasureTracker })
{ formatDisplay(drawDisplay(it)) }
init {
+ FrozenTreasure.entries.forEach { it.chatPattern }
+
fixedRateTimer(name = "skyhanni-frozen-treasure-tracker", period = 1000) {
if (!onJerryWorkshop()) return@fixedRateTimer
calculateIcePerHour()
@@ -120,7 +128,7 @@ object FrozenTreasureTracker {
if (config.hideMessages) event.blockedReason = "frozen treasure tracker"
}
- for (treasure in FrozenTreasure.entries.filter { it.pattern.matches(message) }) {
+ for (treasure in FrozenTreasure.entries.filter { it.chatPattern.matches(message) }) {
tracker.modify {
it.treasuresMined += 1
it.treasureCount.addOrPut(treasure, 1)
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/christmas/PresentWaypoints.kt b/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/christmas/PresentWaypoints.kt
index a6fa577e4..257e69f3d 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/christmas/PresentWaypoints.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/christmas/PresentWaypoints.kt
@@ -17,6 +17,7 @@ import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText
import at.hannibal2.skyhanni.utils.StringUtils.matches
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
// todo: create abstract class for this and BasketWaypoints
@@ -30,10 +31,19 @@ class PresentWaypoints {
private val presentSet get() = presentLocations[HypixelData.lobbyType]
private val presentEntranceSet get() = presentEntranceLocations[HypixelData.lobbyType]
- // TODO use repo pattern
- private val presentAlreadyFoundPattern = "§cYou have already found this present!".toPattern()
- private val presentFoundPattern = "§aYou found a.*present! §r§e\\(§r§b\\d+§r§e/§r§b\\d+§r§e\\)".toPattern()
- private val allFoundPattern = "§aCongratulations! You found all the presents in every lobby!".toPattern()
+ private val patternGroup = RepoPattern.group("event.lobby.waypoint.presents")
+ private val presentAlreadyFoundPattern by patternGroup.pattern(
+ "foundalready",
+ "§cYou have already found this present!"
+ )
+ private val presentFoundPattern by patternGroup.pattern(
+ "found",
+ "§aYou found a.*present! §r§e\\(§r§b\\d+§r§e/§r§b\\d+§r§e\\)"
+ )
+ private val allFoundPattern by patternGroup.pattern(
+ "foundall",
+ "§aCongratulations! You found all the presents in every lobby!"
+ )
@SubscribeEvent
fun onWorldChange(event: LorenzWorldChangeEvent) {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/winter/UniqueGiftCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/event/winter/UniqueGiftCounter.kt
index a039bd339..107156f2e 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/winter/UniqueGiftCounter.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/winter/UniqueGiftCounter.kt
@@ -12,6 +12,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber
import at.hannibal2.skyhanni.utils.RenderUtils.renderString
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
object UniqueGiftCounter {
@@ -19,7 +20,10 @@ object UniqueGiftCounter {
private val config get() = SkyHanniMod.feature.event.winter.uniqueGiftCounter
private val storage get() = ProfileStorageData.playerSpecific?.winter
- private val pattern = "§7Unique Players Gifted: §a(?<amount>.*)".toPattern()
+ private val giftedAmountPattern by RepoPattern.pattern(
+ "event.winter.uniqugifts.counter.amount",
+ "§7Unique Players Gifted: §a(?<amount>.*)"
+ )
private var display = ""
@@ -31,7 +35,7 @@ object UniqueGiftCounter {
val storage = storage ?: return
for (line in item.getLore()) {
- pattern.matchMatcher(line) {
+ giftedAmountPattern.matchMatcher(line) {
val amount = group("amount").formatNumber().toInt()
storage.amountGifted = amount
update()
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitTracker.kt
index f8e5f8a2f..33ad68dcd 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitTracker.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitTracker.kt
@@ -20,6 +20,7 @@ import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.renderables.Renderable
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import at.hannibal2.skyhanni.utils.tracker.ItemTrackerData
import at.hannibal2.skyhanni.utils.tracker.SkyHanniItemTracker
import at.hannibal2.skyhanni.utils.tracker.SkyHanniTracker
@@ -35,7 +36,10 @@ object FishingProfitTracker {
val config get() = SkyHanniMod.feature.fishing.fishingProfitTracker
- private val coinsChatPattern = ".* CATCH! §r§bYou found §r§6(?<coins>.*) Coins§r§b\\.".toPattern()
+ private val coinsChatPattern by RepoPattern.pattern(
+ "fishing.tracker.chat.coins",
+ ".* CATCH! §r§bYou found §r§6(?<coins>.*) Coins§r§b\\."
+ )
private var lastCatchTime = SimpleTimeMark.farPast()
private val tracker = SkyHanniItemTracker(
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/SeaCreatureTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/SeaCreatureTracker.kt
index 34c94d198..e39e8fb11 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/SeaCreatureTracker.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/SeaCreatureTracker.kt
@@ -32,12 +32,13 @@ object SeaCreatureTracker {
private val config get() = SkyHanniMod.feature.fishing.seaCreatureTracker
- private val tracker = SkyHanniTracker("Sea Creature Tracker", { Data() }, { it.fishing.seaCreatureTracker })
- { drawDisplay(it) }
private val trophyArmorNames by RepoPattern.pattern(
"fishing.trophyfishing.armor",
"(BRONZE|SILVER|GOLD|DIAMOND)_HUNTER_(HELMET|CHESTPLATE|LEGGINGS|BOOTS)"
)
+
+ private val tracker = SkyHanniTracker("Sea Creature Tracker", { Data() }, { it.fishing.seaCreatureTracker })
+ { drawDisplay(it) }
private var lastArmorCheck = SimpleTimeMark.farPast()
private var isTrophyFishing = false
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishMessages.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishMessages.kt
index 507e3e7bb..cd8f367dd 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishMessages.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishMessages.kt
@@ -14,15 +14,18 @@ import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.NumberUtil.ordinal
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.util.ChatComponentText
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class TrophyFishMessages {
-
- private val trophyFishPattern =
- "§6§lTROPHY FISH! §r§bYou caught an? §r(?<displayName>§[0-9a-f](?:§k)?[\\w -]+) §r(?<displayRarity>§[0-9a-f]§l\\w+)§r§b\\.".toPattern()
private val config get() = SkyHanniMod.feature.fishing.trophyFishing.chatMessages
+ private val trophyFishPattern by RepoPattern.pattern(
+ "fishing.trophy.trophyfish",
+ "§6§lTROPHY FISH! §r§bYou caught an? §r(?<displayName>§[0-9a-f](?:§k)?[\\w -]+) §r(?<displayRarity>§[0-9a-f]§l\\w+)§r§b\\."
+ )
+
@SubscribeEvent
fun onStatusBar(event: LorenzChatEvent) {
if (!LorenzUtils.inSkyBlock) return
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt
index 5b066b142..46cd544a1 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt
@@ -29,23 +29,69 @@ import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getFarmingForDummie
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getHoeCounter
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.item.ItemStack
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.math.floor
import kotlin.math.log10
import kotlin.time.Duration.Companion.seconds
-class FarmingFortuneDisplay {
-
- private val tabFortuneUniversalPattern = " Farming Fortune: §r§6☘(?<fortune>\\d+)".toPattern()
- private val tabFortuneCropPattern =
- " (?<crop>Wheat|Carrot|Potato|Pumpkin|Sugar Cane|Melon|Cactus|Cocoa Beans|Mushroom|Nether Wart) Fortune: §r§6☘(?<fortune>\\d+)".toPattern()
+object FarmingFortuneDisplay {
+ private val config get() = GardenAPI.config.farmingFortunes
+
+ private val patternGroup = RepoPattern.group("garden.fortunedisplay")
+ private val universalTabFortunePattern by patternGroup.pattern(
+ "tablist.universal",
+ " Farming Fortune: §r§6☘(?<fortune>\\d+)"
+ )
+ private val cropSpecificTabFortunePattern by patternGroup.pattern(
+ "tablist.cropspecific",
+ " (?<crop>Wheat|Carrot|Potato|Pumpkin|Sugar Cane|Melon|Cactus|Cocoa Beans|Mushroom|Nether Wart) Fortune: §r§6☘(?<fortune>\\d+)"
+ )
+ private val collectionPattern by patternGroup.pattern(
+ "collection",
+ "§7You have §6\\+(?<ff>\\d{1,3})☘ .*"
+ )
+ private val tooltipFortunePattern by patternGroup.pattern(
+ "tooltip",
+ "^§7Farming Fortune: §a\\+([\\d.]+)(?: §2\\(\\+\\d\\))?(?: §9\\(\\+(\\d+)\\))?\$"
+ )
+ private val armorAbilityPattern by patternGroup.pattern(
+ "armorability",
+ "Tiered Bonus: .* [(](?<pieces>.*)/4[)]"
+ )
+ private val lotusAbilityPattern by patternGroup.pattern(
+ "lotusability",
+ "§7Piece Bonus: §6+(?<bonus>.*)☘"
+ )
+ // todo make pattern work on Melon and Cropie armor
+ private val armorAbilityFortunePattern by patternGroup.pattern(
+ "armorabilityfortune",
+ "§7.*§7Grants §6(?<bonus>.*)☘.*"
+ )
private var display = emptyList<List<Any>>()
private var accessoryProgressDisplay = ""
private var lastToolSwitch = SimpleTimeMark.farPast()
+ private val latestFF: MutableMap<CropType, Double>? get() = GardenAPI.storage?.latestTrueFarmingFortune
+
+ private var currentCrop: CropType? = null
+
+ private var tabFortuneUniversal: Double = 0.0
+ private var tabFortuneCrop: Double = 0.0
+ private val upgradeFortune: Double? get() = currentCrop?.getUpgradeLevel()?.let { it * 5.0 }
+ private val accessoryFortune: Double?
+ get() = currentCrop?.let {
+ CropAccessoryData.cropAccessory?.getFortune(it)
+ }
+
+ var displayedFortune = 0.0
+ var reforgeFortune = 0.0
+ var itemBaseFortune = 0.0
+ var greenThumbFortune = 0.0
+
@SubscribeEvent
fun onPreProfileSwitch(event: PreProfileSwitchEvent) {
display = emptyList()
@@ -56,10 +102,10 @@ class FarmingFortuneDisplay {
fun onTabListUpdate(event: TabListUpdateEvent) {
if (!GardenAPI.inGarden()) return
event.tabList.firstNotNullOfOrNull {
- tabFortuneUniversalPattern.matchMatcher(it) {
+ universalTabFortunePattern.matchMatcher(it) {
tabFortuneUniversal = group("fortune").toDouble()
}
- tabFortuneCropPattern.matchMatcher(it) {
+ cropSpecificTabFortunePattern.matchMatcher(it) {
currentCrop = CropType.getByName(group("crop"))
tabFortuneCrop = group("fortune").toDouble()
}
@@ -170,131 +216,102 @@ class FarmingFortuneDisplay {
else -> 75
}
- companion object {
-
- private val config get() = GardenAPI.config.farmingFortunes
- private val latestFF: MutableMap<CropType, Double>? get() = GardenAPI.storage?.latestTrueFarmingFortune
-
- private var currentCrop: CropType? = null
+ fun getToolFortune(tool: ItemStack?): Double = getToolFortune(tool?.getInternalName())
+ fun getToolFortune(internalName: NEUInternalName?): Double {
+ if (internalName == null) return 0.0
+ if (internalName.equals("THEORETICAL_HOE")) {
+ return 0.0
+ }
+ return if (internalName.startsWith("THEORETICAL_HOE")) {
+ listOf(10.0, 25.0, 50.0)[internalName.asString().last().digitToInt() - 1]
+ } else when (internalName.asString()) {
+ "FUNGI_CUTTER" -> 30.0
+ "COCO_CHOPPER" -> 20.0
+ else -> 0.0
+ }
+ }
- private var tabFortuneUniversal: Double = 0.0
- private var tabFortuneCrop: Double = 0.0
- private val upgradeFortune: Double? get() = currentCrop?.getUpgradeLevel()?.let { it * 5.0 }
- private val accessoryFortune: Double?
- get() = currentCrop?.let {
- CropAccessoryData.cropAccessory?.getFortune(it)
- }
+ fun getTurboCropFortune(tool: ItemStack?, cropType: CropType?): Double {
+ val crop = cropType ?: return 0.0
+ return tool?.getEnchantments()?.get(crop.getTurboCrop())?.let { it * 5.0 } ?: 0.0
+ }
- private val collectionPattern = "§7You have §6\\+(?<ff>\\d{1,3})☘ .*".toPattern()
- private val tooltipFortunePattern =
- "^§7Farming Fortune: §a\\+([\\d.]+)(?: §2\\(\\+\\d\\))?(?: §9\\(\\+(\\d+)\\))?$".toRegex()
- private val armorAbilityPattern = "Tiered Bonus: .* [(](?<pieces>.*)/4[)]".toPattern()
-
- var displayedFortune = 0.0
- var reforgeFortune = 0.0
- var itemBaseFortune = 0.0
- var greenThumbFortune = 0.0
-
- fun getToolFortune(tool: ItemStack?): Double = getToolFortune(tool?.getInternalName())
- fun getToolFortune(internalName: NEUInternalName?): Double {
- if (internalName == null) return 0.0
- if (internalName.equals("THEORETICAL_HOE")) {
- return 0.0
- }
- return if (internalName.startsWith("THEORETICAL_HOE")) {
- listOf(10.0, 25.0, 50.0)[internalName.asString().last().digitToInt() - 1]
- } else when (internalName.asString()) {
- "FUNGI_CUTTER" -> 30.0
- "COCO_CHOPPER" -> 20.0
- else -> 0.0
- }
- }
+ fun getCollectionFortune(tool: ItemStack?): Double {
+ val string = tool?.getLore()?.nextAfter("§6Collection Analysis", 3) ?: return 0.0
+ return collectionPattern.matchMatcher(string) { group("ff").toDoubleOrNull() } ?: 0.0
+ }
- fun getTurboCropFortune(tool: ItemStack?, cropType: CropType?): Double {
- val crop = cropType ?: return 0.0
- return tool?.getEnchantments()?.get(crop.getTurboCrop())?.let { it * 5.0 } ?: 0.0
- }
+ fun getCounterFortune(tool: ItemStack?): Double {
+ val counter = tool?.getHoeCounter() ?: return 0.0
+ val digits = floor(log10(counter.toDouble()))
+ return (16 * digits - 48).coerceAtLeast(0.0)
+ }
- fun getCollectionFortune(tool: ItemStack?): Double {
- val string = tool?.getLore()?.nextAfter("§6Collection Analysis", 3) ?: return 0.0
- return collectionPattern.matchMatcher(string) { group("ff").toDoubleOrNull() } ?: 0.0
- }
+ fun getDedicationFortune(tool: ItemStack?, cropType: CropType?): Double {
+ if (cropType == null) return 0.0
+ val dedicationLevel = tool?.getEnchantments()?.get("dedication") ?: 0
+ val dedicationMultiplier = listOf(0.0, 0.5, 0.75, 1.0, 2.0)[dedicationLevel]
+ val cropMilestone = GardenCropMilestones.getTierForCropCount(
+ cropType.getCounter(), cropType
+ )
+ return dedicationMultiplier * cropMilestone
+ }
- fun getCounterFortune(tool: ItemStack?): Double {
- val counter = tool?.getHoeCounter() ?: return 0.0
- val digits = floor(log10(counter.toDouble()))
- return (16 * digits - 48).coerceAtLeast(0.0)
- }
+ fun getSunderFortune(tool: ItemStack?) = (tool?.getEnchantments()?.get("sunder") ?: 0) * 12.5
+ fun getHarvestingFortune(tool: ItemStack?) = (tool?.getEnchantments()?.get("harvesting") ?: 0) * 12.5
+ fun getCultivatingFortune(tool: ItemStack?) = (tool?.getEnchantments()?.get("cultivating") ?: 0) * 2.0
- fun getDedicationFortune(tool: ItemStack?, cropType: CropType?): Double {
- if (cropType == null) return 0.0
- val dedicationLevel = tool?.getEnchantments()?.get("dedication") ?: 0
- val dedicationMultiplier = listOf(0.0, 0.5, 0.75, 1.0, 2.0)[dedicationLevel]
- val cropMilestone = GardenCropMilestones.getTierForCropCount(
- cropType.getCounter(), cropType
- )
- return dedicationMultiplier * cropMilestone
- }
+ fun getAbilityFortune(item: ItemStack?) = item?.let {
+ getAbilityFortune(it.getInternalName(), it.getLore())
+ } ?: 0.0
- fun getSunderFortune(tool: ItemStack?) = (tool?.getEnchantments()?.get("sunder") ?: 0) * 12.5
- fun getHarvestingFortune(tool: ItemStack?) = (tool?.getEnchantments()?.get("harvesting") ?: 0) * 12.5
- fun getCultivatingFortune(tool: ItemStack?) = (tool?.getEnchantments()?.get("cultivating") ?: 0) * 2.0
-
- fun getAbilityFortune(item: ItemStack?) = item?.let {
- getAbilityFortune(it.getInternalName(), it.getLore())
- } ?: 0.0
-
- fun getAbilityFortune(internalName: NEUInternalName, lore: List<String>): Double {
- val lotusAbilityPattern = "§7Piece Bonus: §6+(?<bonus>.*)☘".toPattern()
- // todo make it work on Melon and Cropie armor
- val armorAbilityFortune = "§7.*§7Grants §6(?<bonus>.*)☘.*".toPattern()
- var pieces = 0
-
- lore.forEach { line ->
- if (internalName.contains("LOTUS")) {
- lotusAbilityPattern.matchMatcher(line) {
- return group("bonus").toDouble()
- }
- }
- armorAbilityPattern.matchMatcher(line.removeColor()) {
- pieces = group("pieces").toInt()
- }
+ fun getAbilityFortune(internalName: NEUInternalName, lore: List<String>): Double {
+ var pieces = 0
- armorAbilityFortune.matchMatcher(line) {
- return if (pieces < 2) 0.0 else group("bonus").toDouble() / pieces
+ lore.forEach { line ->
+ if (internalName.contains("LOTUS")) {
+ lotusAbilityPattern.matchMatcher(line) {
+ return group("bonus").toDouble()
}
}
+ armorAbilityPattern.matchMatcher(line.removeColor()) {
+ pieces = group("pieces").toInt()
+ }
- return 0.0
+ armorAbilityFortunePattern.matchMatcher(line) {
+ return if (pieces < 2) 0.0 else group("bonus").toDouble() / pieces
+ }
}
- fun loadFortuneLineData(tool: ItemStack?, enchantmentFortune: Double) {
- displayedFortune = 0.0
- reforgeFortune = 0.0
- itemBaseFortune = 0.0
- greenThumbFortune = 0.0
- for (line in tool?.getLore()!!) {
- val match = tooltipFortunePattern.matchEntire(line)?.groups ?: continue
-
- displayedFortune = match[1]!!.value.toDouble()
- reforgeFortune = match[2]?.value?.toDouble() ?: 0.0
-
- itemBaseFortune = if (tool.getInternalName().contains("LOTUS")) {
- 5.0
- } else {
- val dummiesFF = (tool.getFarmingForDummiesCount() ?: 0) * 1.0
- displayedFortune - reforgeFortune - enchantmentFortune - dummiesFF
- }
- greenThumbFortune = if (tool.getInternalName().contains("LOTUS")) {
- displayedFortune - reforgeFortune - itemBaseFortune
- } else 0.0
+ return 0.0
+ }
+
+ fun loadFortuneLineData(tool: ItemStack?, enchantmentFortune: Double) {
+ displayedFortune = 0.0
+ reforgeFortune = 0.0
+ itemBaseFortune = 0.0
+ greenThumbFortune = 0.0
+ for (line in tool?.getLore()!!) {
+ tooltipFortunePattern.matchMatcher(line) {
+ displayedFortune = group(1)!!.toDouble()
+ reforgeFortune = group(2)?.toDouble() ?: 0.0
+ } ?: continue
+
+ itemBaseFortune = if (tool.getInternalName().contains("LOTUS")) {
+ 5.0
+ } else {
+ val dummiesFF = (tool.getFarmingForDummiesCount() ?: 0) * 1.0
+ displayedFortune - reforgeFortune - enchantmentFortune - dummiesFF
}
+ greenThumbFortune = if (tool.getInternalName().contains("LOTUS")) {
+ displayedFortune - reforgeFortune - itemBaseFortune
+ } else 0.0
}
+ }
- fun getCurrentFarmingFortune() = tabFortuneUniversal + tabFortuneCrop
+ fun getCurrentFarmingFortune() = tabFortuneUniversal + tabFortuneCrop
- fun CropType.getLatestTrueFarmingFortune() = latestFF?.get(this)
- }
+ fun CropType.getLatestTrueFarmingFortune() = latestFF?.get(this)
@SubscribeEvent
fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneFix.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneFix.kt
index 838b3f6ce..bba86c595 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneFix.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneFix.kt
@@ -11,12 +11,19 @@ import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class GardenCropMilestoneFix {
-
- private val tabListPattern = " Milestone: §r§a(?<crop>.*) (?<tier>.*): §r§3(?<percentage>.*)%".toPattern()
- private val levelUpPattern = " {2}§r§b§lGARDEN MILESTONE §3(?<crop>.*) §8.*➜§3(?<tier>.*)".toPattern()
+ private val patternGroup = RepoPattern.group("garden.cropmilestone.fix")
+ private val tabListPattern by patternGroup.pattern(
+ "tablist",
+ " Milestone: §r§a(?<crop>.*) (?<tier>.*): §r§3(?<percentage>.*)%"
+ )
+ private val levelUpPattern by patternGroup.pattern(
+ "levelup",
+ " {2}§r§b§lGARDEN MILESTONE §3(?<crop>.*) §8.*➜§3(?<tier>.*)"
+ )
private val tabListCropProgress = mutableMapOf<CropType, Long>()
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 21fb1a78a..d69b92bb3 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt
@@ -21,21 +21,27 @@ import kotlin.time.Duration.Companion.milliseconds
class GardenLevelDisplay {
private val config get() = GardenAPI.config.gardenLevels
- private val expToNextLevelPattern by RepoPattern.pattern(
- "garden.level.inventory.nextxp",
+
+ private val patternGroup = RepoPattern.group("garden.level")
+ private val expToNextLevelPattern by patternGroup.pattern(
+ "inventory.nextxp",
".* §e(?<nextLevelExp>.*)§6/.*"
)
- private val overflowPattern by RepoPattern.pattern("garden.level.inventory.overflow", ".*§r §6(?<overflow>.*)")
- private val currentLevelPattern by RepoPattern.pattern(
- "garden.level.inventory.currentlevel",
+ private val overflowPattern by patternGroup.pattern(
+ "inventory.overflow",
+ ".*§r §6(?<overflow>.*)"
+ )
+ private val currentLevelPattern by patternGroup.pattern(
+ "inventory.currentlevel",
"Garden Level (?<currentLevel>.*)"
)
- private var display = ""
- private val visitorRewardPattern by RepoPattern.pattern(
- "garden.level.chat.increase",
+ private val visitorRewardPattern by patternGroup.pattern(
+ "chat.increase",
" {4}§r§8\\+§r§2(?<exp>.*) §r§7Garden Experience"
)
+ private var display = ""
+
@SubscribeEvent
fun onProfileJoin(event: ProfileJoinEvent) {
update()
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 22c6cb7fc..2ad7d11fd 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt
@@ -27,6 +27,7 @@ import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.TabListData
import at.hannibal2.skyhanni.utils.TimeUtils.format
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import com.google.gson.Gson
import io.github.moulberry.notenoughupdates.util.SkyBlockTime
import kotlinx.coroutines.Dispatchers
@@ -54,9 +55,19 @@ object GardenNextJacobContest {
var contests = mutableMapOf<SimpleTimeMark, FarmingContest>()
private var inCalendar = false
- private val patternDay = "§aDay (?<day>.*)".toPattern()
- private val patternMonth = "(?<month>.*), Year (?<year>.*)".toPattern()
- private val patternCrop = "§(e○|6☘) §7(?<crop>.*)".toPattern()
+ private val patternGroup = RepoPattern.group("garden.nextcontest")
+ private val dayPattern by patternGroup.pattern(
+ "day",
+ "§aDay (?<day>.*)"
+ )
+ private val monthPattern by patternGroup.pattern(
+ "month",
+ "(?<month>.*), Year (?<year>.*)"
+ )
+ private val cropPattern by patternGroup.pattern(
+ "crop",
+ "§(e○|6☘) §7(?<crop>.*)"
+ )
private val closeToNewYear = "§7Close to new SB year!"
private const val maxContestsPerYear = 124
@@ -140,7 +151,7 @@ object GardenNextJacobContest {
inCalendar = true
- patternMonth.matchMatcher(event.inventoryName) {
+ monthPattern.matchMatcher(event.inventoryName) {
val month = LorenzUtils.getSBMonthByName(group("month"))
val year = group("year").toInt()
@@ -175,13 +186,13 @@ object GardenNextJacobContest {
if (!lore.any { it.contains("§6§eJacob's Farming Contest") }) continue
val name = item.name ?: continue
- val day = patternDay.matchMatcher(name) { group("day").toInt() } ?: continue
+ val day = dayPattern.matchMatcher(name) { group("day").toInt() } ?: continue
val startTime = SkyBlockTime(year, month, day).asTimeMark()
val crops = mutableListOf<CropType>()
for (line in lore) {
- patternCrop.matchMatcher(line) { crops.add(CropType.getByName(group("crop"))) }
+ cropPattern.matchMatcher(line) { crops.add(CropType.getByName(group("crop"))) }
}
contests[startTime] = FarmingContest(startTime + contestDuration, crops)
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 56d3fe17d..3f1021bcb 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt
@@ -15,6 +15,7 @@ import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.renderables.Renderable
import io.github.moulberry.moulconfig.observer.Property
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.inventory.GuiEditSign
import net.minecraftforge.client.event.GuiOpenEvent
@@ -26,6 +27,12 @@ import kotlin.time.Duration.Companion.seconds
class GardenOptimalSpeed {
private val config get() = GardenAPI.config.optimalSpeeds
+
+ private val currentSpeedPattern by RepoPattern.pattern(
+ "garden.optimalspeed.currentspeed",
+ " Speed: §r§f✦(?<speed>.*)"
+ )
+
private val configCustomSpeed get() = config.customSpeed
private var sneakingTime = 0.seconds
private val sneaking get() = Minecraft.getMinecraft().thePlayer.isSneaking
@@ -37,7 +44,6 @@ class GardenOptimalSpeed {
_currentSpeed = value
}
private var optimalSpeed = -1
- private val currentSpeedPattern = " Speed: §r§f✦(?<speed>.*)".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/GardenPlotAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotAPI.kt
index f1edf26e9..58a56c400 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotAPI.kt
@@ -23,10 +23,13 @@ import kotlin.time.Duration.Companion.minutes
object GardenPlotAPI {
- private val plotNamePattern by RepoPattern.pattern("garden.plot.name", "§.Plot §7- §b(?<name>.*)")
-
- private val plotSprayedPattern by RepoPattern.pattern(
- "garden.plot.spray.target",
+ private val patternGroup = RepoPattern.group("garden.plot")
+ private val plotNamePattern by patternGroup.pattern(
+ "name",
+ "§.Plot §7- §b(?<name>.*)"
+ )
+ private val plotSprayedPattern by patternGroup.pattern(
+ "spray.target",
"§a§lSPRAYONATOR! §r§7You sprayed §r§aPlot §r§7- §r§b(?<plot>.*) §r§7with §r§a(?<spray>.*)§r§7!"
)
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenWarpCommands.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenWarpCommands.kt
index 563258b95..fc30e3651 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenWarpCommands.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenWarpCommands.kt
@@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.NEUItems
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.client.Minecraft
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.time.Duration.Companion.seconds
@@ -16,8 +17,11 @@ class GardenWarpCommands {
private val config get() = GardenAPI.config.gardenCommands
- // TODO repo
- private val tpPlotPattern = "/tp (?<plot>.*)".toPattern()
+ private val tpPlotPattern by RepoPattern.pattern(
+ "garden.warpcommand.tpplot",
+ "/tp (?<plot>.*)"
+ )
+
private var lastWarpTime = SimpleTimeMark.farPast()
@SubscribeEvent
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/ToolTooltipTweaks.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/ToolTooltipTweaks.kt
index 56568f017..70dbcb1e8 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/ToolTooltipTweaks.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/ToolTooltipTweaks.kt
@@ -3,7 +3,7 @@ package at.hannibal2.skyhanni.features.garden
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.config.features.garden.TooltipTweaksConfig.CropTooltipFortuneEntry
import at.hannibal2.skyhanni.events.LorenzToolTipEvent
-import at.hannibal2.skyhanni.features.garden.FarmingFortuneDisplay.Companion.getAbilityFortune
+import at.hannibal2.skyhanni.features.garden.FarmingFortuneDisplay.getAbilityFortune
import at.hannibal2.skyhanni.features.garden.GardenAPI.getCropType
import at.hannibal2.skyhanni.features.garden.fortuneguide.FFGuideGUI
import at.hannibal2.skyhanni.utils.ConfigUtils
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 f883f5de1..acb62abe2 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
@@ -8,12 +8,20 @@ import at.hannibal2.skyhanni.utils.NumberUtil
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
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
class ComposterInventoryNumbers {
- private val valuePattern = ".* §e(?<having>.*)§6/(?<total>.*)".toPattern()
- private val compostsPattern = "§7§7Compost Available: §a(?<amount>.*)".toPattern()
+ private val patternGroup = RepoPattern.group("garden.composter.inventory.numbers")
+ private val valuePattern by patternGroup.pattern(
+ "value",
+ ".* §e(?<having>.*)§6/(?<total>.*)"
+ )
+ private val amountPattern by patternGroup.pattern(
+ "amount",
+ "§7§7Compost Available: §a(?<amount>.*)"
+ )
@SubscribeEvent
fun onRenderItemTip(event: RenderInventoryItemTipEvent) {
@@ -29,7 +37,7 @@ class ComposterInventoryNumbers {
// Composts Available
if (slotNumber == 13) {
for (line in stack.getLore()) {
- compostsPattern.matchMatcher(line) {
+ amountPattern.matchMatcher(line) {
val total = group("amount").replace(",", "").toInt()
event.offsetY = -2
event.offsetX = -20
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/ContestBracket.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/ContestBracket.kt
index 9ee04d3fc..eb091668a 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/ContestBracket.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/ContestBracket.kt
@@ -1,5 +1,7 @@
package at.hannibal2.skyhanni.features.garden.contest
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
+
enum class ContestBracket(val color: String) {
DIAMOND("b"),
PLATINUM("3"),
@@ -9,5 +11,8 @@ enum class ContestBracket(val color: String) {
;
val displayName = "§$color§l$name"
- val pattern = "$displayName §7\\(§bTop \\d{1,2}%§7\\): §6(?<amount>.*)".toPattern()
+ val bracketPattern by RepoPattern.pattern(
+ "garden.farming.contest.bracket" + this.name.lowercase(),
+ "$displayName §7\\(§bTop \\d{1,2}%§7\\): §6(?<amount>.*)"
+ )
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt
index b70fc9934..727c86ef0 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt
@@ -15,6 +15,7 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import io.github.moulberry.notenoughupdates.util.SkyBlockTime
import net.minecraft.item.ItemStack
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -22,16 +23,30 @@ import kotlin.time.Duration.Companion.minutes
object FarmingContestAPI {
- private val timePattern = "§a(?<month>.*) (?<day>.*)(?:rd|st|nd|th), Year (?<year>.*)".toPattern()
+ private val patternGroup = RepoPattern.group("garden.farming.contest")
+ private val timePattern by patternGroup.pattern(
+ "time",
+ "§a(?<month>.*) (?<day>.*)(?:rd|st|nd|th), Year (?<year>.*)"
+ )
+ private val cropPattern by patternGroup.pattern(
+ "crop",
+ "§8(?<crop>.*) Contest"
+ )
+ private val sidebarCropPattern by patternGroup.pattern(
+ "sidebarcrop",
+ "(?:§e○|§6☘) §f(?<crop>.*) §a.*"
+ )
+
private val contests = mutableMapOf<Long, FarmingContest>()
- private val cropPattern = "§8(?<crop>.*) Contest".toPattern()
var inContest = false
var contestCrop: CropType? = null
private var startTime = SimpleTimeMark.farPast()
- private val sidebarCropPattern = "(?:§e○|§6☘) §f(?<crop>.*) §a.*".toPattern()
-
var inInventory = false
+ init {
+ ContestBracket.entries.forEach { it.bracketPattern }
+ }
+
@SubscribeEvent
fun onTick(event: LorenzTickEvent) {
if (event.repeatSeconds(1)) {
@@ -116,7 +131,7 @@ object FarmingContestAPI {
val brackets = buildMap {
for (bracket in ContestBracket.entries) {
val amount = lore.firstNotNullOfOrNull {
- bracket.pattern.matchMatcher(it) {
+ bracket.bracketPattern.matchMatcher(it) {
group("amount").replace(",", "").toInt()
}
} ?: continue
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestFFNeededDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestFFNeededDisplay.kt
index 8b8150cc8..da38c318b 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestFFNeededDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestFFNeededDisplay.kt
@@ -4,7 +4,7 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.InventoryCloseEvent
import at.hannibal2.skyhanni.events.RenderItemTooltipEvent
import at.hannibal2.skyhanni.features.garden.CropType
-import at.hannibal2.skyhanni.features.garden.FarmingFortuneDisplay.Companion.getLatestTrueFarmingFortune
+import at.hannibal2.skyhanni.features.garden.FarmingFortuneDisplay.getLatestTrueFarmingFortune
import at.hannibal2.skyhanni.features.garden.GardenAPI
import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.getLatestBlocksPerSecond
import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestTimeNeeded.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestTimeNeeded.kt
index 7f6a91c33..c493bd6ca 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestTimeNeeded.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestTimeNeeded.kt
@@ -3,7 +3,7 @@ package at.hannibal2.skyhanni.features.garden.contest
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.InventoryUpdatedEvent
import at.hannibal2.skyhanni.features.garden.CropType
-import at.hannibal2.skyhanni.features.garden.FarmingFortuneDisplay.Companion.getLatestTrueFarmingFortune
+import at.hannibal2.skyhanni.features.garden.FarmingFortuneDisplay.getLatestTrueFarmingFortune
import at.hannibal2.skyhanni.features.garden.GardenAPI
import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.getLatestBlocksPerSecond
import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/ArmorDropTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/ArmorDropTracker.kt
index 7e91764dd..f4e48b626 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/ArmorDropTracker.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/ArmorDropTracker.kt
@@ -19,6 +19,7 @@ import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.SimpleTimeMark
+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.JsonObject
@@ -28,10 +29,15 @@ import kotlin.time.Duration.Companion.seconds
object ArmorDropTracker {
- private var hasArmor = false
- private val armorPattern = "(FERMENTO|CROPIE|SQUASH|MELON)_(LEGGINGS|CHESTPLATE|BOOTS|HELMET)".toPattern()
private val config get() = GardenAPI.config.farmingArmorDrop
+ private val armorPattern by RepoPattern.pattern(
+ "garden.armordrops.armor",
+ "(FERMENTO|CROPIE|SQUASH|MELON)_(LEGGINGS|CHESTPLATE|BOOTS|HELMET)"
+ )
+
+ private var hasArmor = false
+
private val tracker = SkyHanniTracker("Armor Drop Tracker", { Data() }, { it.garden.armorDropTracker })
{ drawDisplay(it) }
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerRngDropTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerRngDropTracker.kt
index 000772cbc..592705bb7 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerRngDropTracker.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerRngDropTracker.kt
@@ -13,6 +13,7 @@ import at.hannibal2.skyhanni.utils.CollectionUtils.sortedDesc
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
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.annotations.Expose
@@ -36,24 +37,41 @@ object DicerRngDropTracker {
var drops: MutableMap<CropType, MutableMap<DropRarity, Int>> = mutableMapOf()
}
- // TODO USE SH-REPO
- private val melonUncommonDropPattern =
- "§a§lUNCOMMON DROP! §r§eDicer dropped §r§a(\\d+)x §r§aEnchanted Melon§r§e!".toPattern()
- private val melonRareDropPattern =
- "§9§lRARE DROP! §r§eDicer dropped §r§a(\\d+)x §r§aEnchanted Melon§r§e!".toPattern()
- private val melonCrazyRareDropPattern =
- "§d§lCRAZY RARE DROP! §r§eDicer dropped §r§[a|9](\\d+)x §r§[a|9]Enchanted Melon(?: Block)?§r§e!".toPattern()
- private val melonRngesusDropPattern =
- "§5§lPRAY TO RNGESUS DROP! §r§eDicer dropped §r§9(\\d+)x §r§9Enchanted Melon Block§r§e!".toPattern()
-
- private val pumpkinUncommonDropPattern =
- "§a§lUNCOMMON DROP! §r§eDicer dropped §r§a(\\d+)x §r§aEnchanted Pumpkin§r§e!".toPattern()
- private val pumpkinRareDropPattern =
- "§9§lRARE DROP! §r§eDicer dropped §r§a(\\d+)x §r§aEnchanted Pumpkin§r§e!".toPattern()
- private val pumpkinCrazyRareDropPattern =
- "§d§lCRAZY RARE DROP! §r§eDicer dropped §r§a(\\d+)x §r§aEnchanted Pumpkin§r§e!".toPattern()
- private val pumpkinRngesusDropPattern =
- "§5§lPRAY TO RNGESUS DROP! §r§eDicer dropped §r§[a|9](\\d+)x §r§(aEnchanted|9Polished) Pumpkin§r§e!".toPattern()
+ private val melonPatternGroup = RepoPattern.group("garden.dicer.melon")
+ private val melonUncommonDropPattern by melonPatternGroup.pattern(
+ "uncommon",
+ "§a§lUNCOMMON DROP! §r§eDicer dropped §r§a(\\d+)x §r§aEnchanted Melon§r§e!"
+ )
+ private val melonRareDropPattern by melonPatternGroup.pattern(
+ "rare",
+ "§9§lRARE DROP! §r§eDicer dropped §r§a(\\d+)x §r§aEnchanted Melon§r§e!"
+ )
+ private val melonCrazyRareDropPattern by melonPatternGroup.pattern(
+ "crazyrare",
+ "§d§lCRAZY RARE DROP! §r§eDicer dropped §r§[a|9](\\d+)x §r§[a|9]Enchanted Melon(?: Block)?§r§e!"
+ )
+ private val melonRngesusDropPattern by melonPatternGroup.pattern(
+ "rngesus",
+ "§5§lPRAY TO RNGESUS DROP! §r§eDicer dropped §r§9(\\d+)x §r§9Enchanted Melon Block§r§e!"
+ )
+
+ private val pumpkinPatternGroup = RepoPattern.group("garden.dicer.pumpkin")
+ private val pumpkinUncommonDropPattern by pumpkinPatternGroup.pattern(
+ "uncommon",
+ "§a§lUNCOMMON DROP! §r§eDicer dropped §r§a(\\d+)x §r§aEnchanted Pumpkin§r§e!"
+ )
+ private val pumpkinRareDropPattern by pumpkinPatternGroup.pattern(
+ "rare",
+ "§9§lRARE DROP! §r§eDicer dropped §r§a(\\d+)x §r§aEnchanted Pumpkin§r§e!"
+ )
+ private val pumpkinCrazyRareDropPattern by pumpkinPatternGroup.pattern(
+ "crazyrare",
+ "§d§lCRAZY RARE DROP! §r§eDicer dropped §r§a(\\d+)x §r§aEnchanted Pumpkin§r§e!"
+ )
+ private val pumpkinRngesusDropPattern by pumpkinPatternGroup.pattern(
+ "rngesus",
+ "§5§lPRAY TO RNGESUS DROP! §r§eDicer dropped §r§[a|9](\\d+)x §r§(aEnchanted|9Polished) Pumpkin§r§e!"
+ )
init {
itemDrops.add(ItemDrop(CropType.MELON, DropRarity.UNCOMMON, melonUncommonDropPattern))
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt
index 89cac9417..c9e872d1d 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt
@@ -27,23 +27,44 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.math.round
import kotlin.time.Duration.Companion.days
-class CaptureFarmingGear {
-
+object CaptureFarmingGear {
private val farmingItems get() = GardenAPI.storage?.fortune?.farmingItems
private val outdatedItems get() = GardenAPI.storage?.fortune?.outdatedItems
- // TODO USE SH-REPO
- private val farmingLevelUpPattern = "SKILL LEVEL UP Farming .*➜(?<level>.*)".toPattern()
- private val fortuneUpgradePattern = "You claimed the Garden Farming Fortune (?<level>.*) upgrade!".toPattern()
- private val anitaBuffPattern = "You tiered up the Extra Farming Drops upgrade to [+](?<level>.*)%!".toPattern()
- private val anitaMenuPattern = "§7You have: §6\\+(?<level>.*)☘ Farming Fortune".toPattern()
-
- private val lotusUpgradePattern = "Lotus (?<piece>.*) upgraded to [+].*☘!".toPattern()
- private val petLevelUpPattern = "Your (?<pet>.*) leveled up to level .*!".toPattern()
-
- private val cakePattern = "(?:Big )?Yum! You (?:gain|refresh) [+]5☘ Farming Fortune for 48 hours!".toPattern()
-
private val patternGroup = RepoPattern.group("garden.fortuneguide.capture")
+ private val farmingLevelUpPattern by patternGroup.pattern(
+ "farminglevel",
+ "SKILL LEVEL UP Farming .*➜(?<level>.*)"
+ )
+ private val fortuneUpgradePattern by patternGroup.pattern(
+ "fortuneupgrade",
+ "You claimed the Garden Farming Fortune (?<level>.*) upgrade!"
+ )
+ private val anitaBuffPattern by patternGroup.pattern(
+ "anitabuff",
+ "You tiered up the Extra Farming Drops upgrade to [+](?<level>.*)%!"
+ )
+ private val anitaMenuPattern by patternGroup.pattern(
+ "anitamenu",
+ "§7You have: §6\\+(?<level>.*)☘ Farming Fortune"
+ )
+ private val lotusUpgradePattern by patternGroup.pattern(
+ "lotusupgrade",
+ "Lotus (?<piece>.*) upgraded to [+].*☘!"
+ )
+ private val petLevelUpPattern by patternGroup.pattern(
+ "petlevelup",
+ "Your (?<pet>.*) leveled up to level .*!"
+ )
+ private val cakePattern by patternGroup.pattern(
+ "cake",
+ "(?:Big )?Yum! You (?:gain|refresh) [+]5☘ Farming Fortune for 48 hours!"
+ )
+ private val strengthPattern by patternGroup.pattern(
+ "strength",
+ " Strength: §r§c❁(?<strength>.*)"
+ )
+
private val tierPattern by patternGroup.pattern(
"uniquevisitors.tier",
"§7Progress to Tier (?<nextTier>\\w+):.*"
@@ -53,69 +74,64 @@ class CaptureFarmingGear {
".* §e(?<having>.*)§6/(?<total>.*)"
)
- companion object {
-
- private val strengthPattern = " Strength: §r§c❁(?<strength>.*)".toPattern()
- private val farmingSets = arrayListOf(
- "FERMENTO", "SQUASH", "CROPIE", "MELON", "FARM",
- "RANCHERS", "FARMER", "RABBIT"
- )
- private val farmingItems get() = GardenAPI.storage?.fortune?.farmingItems
+ private val farmingSets = arrayListOf(
+ "FERMENTO", "SQUASH", "CROPIE", "MELON", "FARM",
+ "RANCHERS", "FARMER", "RABBIT"
+ )
- fun captureFarmingGear() {
- val farmingItems = farmingItems ?: return
- val itemStack = InventoryUtils.getItemInHand() ?: return
+ fun captureFarmingGear() {
+ val farmingItems = farmingItems ?: return
+ val itemStack = InventoryUtils.getItemInHand() ?: return
- val currentCrop = itemStack.getCropType()
+ val currentCrop = itemStack.getCropType()
- if (currentCrop == null) {
- // todo better fall back items
- // todo Daedalus axe
- } else {
- for (item in FarmingItems.entries) {
- if (item.name == currentCrop.name) {
- farmingItems[item] = itemStack
- }
+ if (currentCrop == null) {
+ //todo better fall back items
+ //todo Daedalus axe
+ } else {
+ for (item in FarmingItems.entries) {
+ if (item.name == currentCrop.name) {
+ farmingItems[item] = itemStack
}
}
- for (armor in InventoryUtils.getArmor()) {
- if (armor == null) continue
- val split = armor.getInternalName().asString().split("_")
- if (split.first() in farmingSets) {
- for (item in FarmingItems.entries) {
- if (item.name == split.last()) {
- farmingItems[item] = armor
- }
+ }
+ for (armor in InventoryUtils.getArmor()) {
+ if (armor == null) continue
+ val split = armor.getInternalName().asString().split("_")
+ if (split.first() in farmingSets) {
+ for (item in FarmingItems.entries) {
+ if (item.name == split.last()) {
+ farmingItems[item] = armor
}
}
}
- for (line in TabListData.getTabList()) {
- strengthPattern.matchMatcher(line) {
- GardenAPI.storage?.fortune?.farmingStrength = group("strength").toInt()
- }
+ }
+ for (line in TabListData.getTabList()) {
+ strengthPattern.matchMatcher(line) {
+ GardenAPI.storage?.fortune?.farmingStrength = group("strength").toInt()
}
}
+ }
- fun reverseCarrotFortune() {
- val storage = GardenAPI.storage?.fortune ?: return
- storage.carrotFortune = !storage.carrotFortune
- ChatUtils.chat("Toggled exportable carrot fortune to: ${storage.carrotFortune}")
- }
+ fun reverseCarrotFortune() {
+ val storage = GardenAPI.storage?.fortune ?: return
+ storage.carrotFortune = !storage.carrotFortune
+ ChatUtils.chat("Toggled exportable carrot fortune to: ${storage.carrotFortune}")
+ }
- fun reversePumpkinFortune() {
- val storage = GardenAPI.storage?.fortune ?: return
- storage.pumpkinFortune = !storage.pumpkinFortune
- ChatUtils.chat("Toggled expired pumpkin fortune to: ${storage.pumpkinFortune}")
- }
+ fun reversePumpkinFortune() {
+ val storage = GardenAPI.storage?.fortune ?: return
+ storage.pumpkinFortune = !storage.pumpkinFortune
+ ChatUtils.chat("Toggled expired pumpkin fortune to: ${storage.pumpkinFortune}")
+ }
- private fun getUniqueVisitorsForTier(tier: Int): Int {
- return when {
- tier == 0 -> 0
- tier == 1 -> 1
- tier == 2 -> 5
- tier >= 3 -> 10 * (tier - 2)
- else -> throw IllegalStateException("Unexpected unique visitors tier: $tier")
- }
+ private fun getUniqueVisitorsForTier(tier: Int): Int {
+ return when {
+ tier == 0 -> 0
+ tier == 1 -> 1
+ tier == 2 -> 5
+ tier >= 3 -> 10 * (tier - 2)
+ else -> throw IllegalStateException("Unexpected unique visitors tier: $tier")
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/AnitaExtraFarmingFortune.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/AnitaExtraFarmingFortune.kt
index c9271231c..1ebc5be3b 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/AnitaExtraFarmingFortune.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/AnitaExtraFarmingFortune.kt
@@ -14,11 +14,18 @@ import at.hannibal2.skyhanni.utils.NumberUtil
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 net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class AnitaExtraFarmingFortune {
private val config get() = GardenAPI.config.anitaShop
+
+ private val realAmountPattern by RepoPattern.pattern(
+ "garden.inventory.anita.extrafortune.realamount",
+ "§5§o§aJacob's Ticket §8x(?<realAmount>.*)"
+ )
+
private var levelPrice = mapOf<Int, Price>()
@SubscribeEvent
@@ -34,7 +41,7 @@ class AnitaExtraFarmingFortune {
var contributionFactor = 1.0
val baseAmount = levelPrice[anitaUpgrade + 1]?.jacob_tickets ?: return
for (line in event.toolTip) {
- "§5§o§aJacob's Ticket §8x(?<realAmount>.*)".toPattern().matchMatcher(line) {
+ realAmountPattern.matchMatcher(line) {
val realAmount = group("realAmount").formatNumber().toDouble()
contributionFactor = realAmount / baseAmount
}
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 b87b7bf33..98e2ffb41 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
@@ -11,13 +11,17 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class GardenInventoryNumbers {
private val config get() = GardenAPI.config.number
- private var patternUpgradeTier = "§7Current Tier: §[ea](?<tier>.*)§7/§a.*".toPattern()
+ private val upgradeTierPattern by RepoPattern.pattern(
+ "garden.inventory.numbers.upgradetier",
+ "§7Current Tier: §[ea](?<tier>.*)§7/§a.*"
+ )
@SubscribeEvent
fun onRenderItemTip(event: RenderItemTipEvent) {
@@ -36,7 +40,7 @@ class GardenInventoryNumbers {
if (!config.cropUpgrades) return
event.stack.getLore()
- .map { patternUpgradeTier.matcher(it) }
+ .map { upgradeTierPattern.matcher(it) }
.filter { it.matches() }
.map { it.group("tier") }
.forEach { event.stackTip = "" + it }
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 b304dd43e..81d01f2dd 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
@@ -17,12 +17,17 @@ import at.hannibal2.skyhanni.utils.NEUItems.getPriceOrNull
import at.hannibal2.skyhanni.utils.NumberUtil
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.item.ItemStack
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class SkyMartCopperPrice {
- private val copperPattern = "§c(?<amount>.*) Copper".toPattern()
+ private val copperPattern by RepoPattern.pattern(
+ "garden.inventory.skymart.copper",
+ "§c(?<amount>.*) Copper"
+ )
+
private var display = emptyList<List<Any>>()
private val config get() = GardenAPI.config.skyMart
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestFinder.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestFinder.kt
index c46b73f01..976dc7ad7 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestFinder.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestFinder.kt
@@ -30,6 +30,7 @@ import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.StringUtils
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.renderables.Renderable
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.client.Minecraft
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -39,8 +40,15 @@ class PestFinder {
private val config get() = PestAPI.config.pestFinder
- // TODO repo pattern
- private val pestsInScoreboardPattern = " §7⏣ §[ac]The Garden §4§lൠ§7 x(?<pests>.*)".toPattern()
+ private val patternGroup = RepoPattern.group("garden.pests.finder")
+ private val pestsInScoreboardPattern by patternGroup.pattern(
+ "scoreboard",
+ " §7⏣ §[ac]The Garden §4§lൠ§7 x(?<pests>.*)"
+ )
+ private val pestInventoryPattern by patternGroup.pattern(
+ "inventory",
+ "§4§lൠ §cThis plot has §6(?<amount>\\d) Pests?§c!"
+ )
private var display = emptyList<Renderable>()
private var lastTimeVacuumHold = SimpleTimeMark.farPast()
@@ -63,8 +71,6 @@ class PestFinder {
if (!isEnabled()) return
if (event.inventoryName != "Configure Plots") return
- val pestInventoryPattern = "§4§lൠ §cThis plot has §6(?<amount>\\d) Pests?§c!".toPattern()
-
for (plot in GardenPlotAPI.plots) {
plot.pests = 0
val item = event.inventoryItems[plot.inventorySlot] ?: continue
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestSpawn.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestSpawn.kt
index bc1ae651c..8a4fd511b 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestSpawn.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestSpawn.kt
@@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.utils.ConfigUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.StringUtils
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.time.Duration.Companion.seconds
@@ -18,9 +19,15 @@ class PestSpawn {
private val config get() = PestAPI.config.pestSpawn
- private val patternOnePest = "§6§l.*! §7A §6Pest §7has appeared in §aPlot §7- §b(?<plot>.*)§7!".toPattern()
- private val patternMultiplePests =
- "§6§l.*! §6(?<amount>\\d) Pests §7have spawned in §aPlot §7- §b(?<plot>.*)§7!".toPattern()
+ private val patternGroup = RepoPattern.group("garden.pests.spawn")
+ private val onePestPattern by patternGroup.pattern(
+ "one",
+ "§6§l.*! §7A §6Pest §7has appeared in §aPlot §7- §b(?<plot>.*)§7!"
+ )
+ private val multiplePestSpawn by patternGroup.pattern(
+ "multiple",
+ "§6§l.*! §6(?<amount>\\d) Pests §7have spawned in §aPlot §7- §b(?<plot>.*)§7!"
+ )
@SubscribeEvent
fun onChat(event: LorenzChatEvent) {
@@ -28,11 +35,11 @@ class PestSpawn {
var blocked = false
- patternOnePest.matchMatcher(event.message) {
+ onePestPattern.matchMatcher(event.message) {
pestSpawn(1, group("plot"))
blocked = true
}
- patternMultiplePests.matchMatcher(event.message) {
+ multiplePestSpawn.matchMatcher(event.message) {
pestSpawn(group("amount").toInt(), group("plot"))
blocked = true
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorDropStatistics.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorDropStatistics.kt
index d8042272e..c34fcf433 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorDropStatistics.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorDropStatistics.kt
@@ -22,6 +22,7 @@ import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
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
object GardenVisitorDropStatistics {
@@ -36,13 +37,36 @@ object GardenVisitorDropStatistics {
var lastAccept = 0L
- private val acceptPattern = "OFFER ACCEPTED with (?<visitor>.*) [(](?<rarity>.*)[)]".toPattern()
- private val copperPattern = "[+](?<amount>.*) Copper".toPattern()
- private val gardenExpPattern = "[+](?<amount>.*) Garden Experience".toPattern()
- private val farmingExpPattern = "[+](?<amount>.*) Farming XP".toPattern()
- private val bitsPattern = "[+](?<amount>.*) Bits".toPattern()
- private val mithrilPowderPattern = "[+](?<amount>.*) Mithril Powder".toPattern()
- private val gemstonePowderPattern = "[+](?<amount>.*) Gemstone Powder".toPattern()
+ private val patternGroup = RepoPattern.group("garden.visitor.droptracker")
+ private val acceptPattern by patternGroup.pattern(
+ "accept",
+ "OFFER ACCEPTED with (?<visitor>.*) [(](?<rarity>.*)[)]"
+ )
+ private val copperPattern by patternGroup.pattern(
+ "copper",
+ "[+](?<amount>.*) Copper"
+ )
+ private val gardenExpPattern by patternGroup.pattern(
+ "gardenexp",
+ "[+](?<amount>.*) Garden Experience"
+ )
+ private val farmingExpPattern by patternGroup.pattern(
+ "farmingexp",
+ "[+](?<amount>.*) Farming XP"
+ )
+ private val bitsPattern by patternGroup.pattern(
+ "bits",
+ "[+](?<amount>.*) Bits"
+ )
+ private val mithrilPowderPattern by patternGroup.pattern(
+ "powder.mithril",
+ "[+](?<amount>.*) Mithril Powder"
+ )
+ private val gemstonePowderPattern by patternGroup.pattern(
+ "powder.gemstone",
+ "[+](?<amount>.*) Gemstone Powder"
+ )
+
private var rewardsCount = mapOf<VisitorReward, Int>()
private fun formatDisplay(map: List<List<Any>>): List<List<Any>> {
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 1672857ff..d32b8e75d 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
@@ -73,12 +73,26 @@ private val config get() = VisitorAPI.config
class GardenVisitorFeatures {
private var display = emptyList<List<Any>>()
- private val newVisitorArrivedMessage = ".* §r§ehas arrived on your §r§bGarden§r§e!".toPattern()
- private val copperPattern = " §8\\+§c(?<amount>.*) Copper".toPattern()
- private val gardenExperiencePattern = " §8\\+§2(?<amount>.*) §7Garden Experience".toPattern()
- private val visitorChatMessagePattern = "§e\\[NPC] (§.)?(?<name>.*)§f: §r.*".toPattern()
- private val partialAcceptedPattern by RepoPattern.pattern(
- "garden.visitor.partialaccepted",
+
+ private val patternGroup = RepoPattern.group("garden.visitor")
+ private val visitorArrivePattern by patternGroup.pattern(
+ "visitorarrive",
+ ".* §r§ehas arrived on your §r§bGarden§r§e!"
+ )
+ private val copperPattern by patternGroup.pattern(
+ "copper",
+ " §8\\+§c(?<amount>.*) Copper"
+ )
+ private val gardenExperiencePattern by patternGroup.pattern(
+ "gardenexperience",
+ " §8\\+§2(?<amount>.*) §7Garden Experience"
+ )
+ private val visitorChatMessagePattern by patternGroup.pattern(
+ "visitorchat",
+ "§e\\[NPC] (§.)?(?<name>.*)§f: §r.*"
+ )
+ private val partialAcceptedPattern by patternGroup.pattern(
+ "partialaccepted",
"§aYou gave some of the required items!"
)
@@ -456,8 +470,8 @@ class GardenVisitorFeatures {
}
@SubscribeEvent
- fun onChat(event: LorenzChatEvent) {
- if (config.hypixelArrivedMessage && newVisitorArrivedMessage.matcher(event.message).matches()) {
+ fun onChatMessage(event: LorenzChatEvent) {
+ if (config.hypixelArrivedMessage && visitorArrivePattern.matcher(event.message).matches()) {
event.blockedReason = "new_visitor_arrived"
}
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 6518a2bd7..6d82115a6 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
@@ -18,6 +18,7 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.TabListData
import at.hannibal2.skyhanni.utils.TimeUtils
import at.hannibal2.skyhanni.utils.TimeUtils.format
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.concurrent.fixedRateTimer
import kotlin.time.Duration
@@ -30,7 +31,12 @@ import kotlin.time.toDuration
class GardenVisitorTimer {
private val config get() = GardenAPI.config.visitors.timer
- private val pattern = "§b§lVisitors: §r§f\\((?<time>.*)\\)".toPattern()
+
+ private val timePattern by RepoPattern.pattern(
+ "garden.visitor.timer.time",
+ "§b§lVisitors: §r§f\\((?<time>.*)\\)"
+ )
+
private var display = ""
private var lastMillis = 0.seconds
private var sixthVisitorArrivalTime = SimpleTimeMark.farPast()
@@ -99,7 +105,7 @@ class GardenVisitorTimer {
return
}
- pattern.matchMatcher(line) {
+ timePattern.matchMatcher(line) {
val rawTime = group("time").removeColor()
if (lastTimerValue != rawTime) {
lastTimerUpdate = SimpleTimeMark.now()
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/NPCVisitorFix.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/NPCVisitorFix.kt
index 19edd0d28..ba4a5c80e 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/NPCVisitorFix.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/NPCVisitorFix.kt
@@ -27,7 +27,11 @@ object NPCVisitorFix {
private val storage get() = ProfileStorageData.profileSpecific?.garden
private val staticVisitors = listOf("Jacob", "Anita")
- private val barnSkinChangePattern by RepoPattern.pattern("garden.barn.skin.change", "§aChanging Barn skin to §r.*")
+
+ private val barnSkinChangePattern by RepoPattern.pattern(
+ "garden.barn.skin.change",
+ "§aChanging Barn skin to §r.*"
+ )
@SubscribeEvent
fun onInventoryOpen(event: InventoryOpenEvent) {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt
index 45d5bd7bf..6c8ff6bf8 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt
@@ -19,6 +19,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class AuctionsHighlighter {
private val config get() = SkyHanniMod.feature.inventory
+
private val buyItNowPattern by RepoPattern.pattern(
"auctions.highlight.buyitnow",
"§7Buy it now: §6(?<coins>.*) coins"
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/HarpFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/HarpFeatures.kt
index 645e20510..a9a5f6e7b 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HarpFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HarpFeatures.kt
@@ -46,9 +46,20 @@ object HarpFeatures {
}
private val buttonColors = listOf('d', 'e', 'a', '2', '5', '9', 'b')
- private val inventoryTitlePattern by RepoPattern.pattern("harp.inventory", "Harp.*")
- private val menuTitlePattern by RepoPattern.pattern("harp.menu", "Melody.*")
- private val songSelectedPattern by RepoPattern.pattern("harp.song.selected", "§aSong is selected!")
+
+ private val patternGroup = RepoPattern.group("harp")
+ private val inventoryTitlePattern by patternGroup.pattern(
+ "inventory",
+ "Harp.*"
+ )
+ private val menuTitlePattern by patternGroup.pattern(
+ "menu",
+ "Melody.*"
+ )
+ private val songSelectedPattern by patternGroup.pattern(
+ "song.selected",
+ "§aSong is selected!"
+ )
private fun isHarpGui(chestName: String) = inventoryTitlePattern.matches(chestName)
private fun isMenuGui(chestName: String) = menuTitlePattern.matches(chestName)
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 37c25362e..d768bb844 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt
@@ -42,22 +42,38 @@ import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getEdition
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getRanchersSpeed
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.item.ItemStack
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
object ItemDisplayOverlayFeatures {
-
- // TODO USE SH-REPO
private val config get() = SkyHanniMod.feature.inventory
- // TODO repo
- private val petLevelPattern = "\\[Lvl (?<level>.*)] .*".toPattern()
- private val masterSkullPattern = "(.*)Master Skull - Tier .".toPattern()
- private val gardenVacuumPatterm = "§7Vacuum Bag: §6(?<amount>\\d*) Pests?".toPattern()
- private val harvestPattern = "§7§7You may harvest §6(?<amount>.).*".toPattern()
- private val dungeonPotionPattern = "Dungeon (?<level>.*) Potion".toPattern()
- private val bingoGoalRankPattern =
- "(§.)*You were the (§.)*(?<rank>[\\w]+)(?<ordinal>(st|nd|rd|th)) (§.)*to".toPattern()
+ private val patternGroup = RepoPattern.group("inventory.item.overlay")
+ private val petLevelPattern by patternGroup.pattern(
+ "pet.level",
+ "\\[Lvl (?<level>\\d+)] .*"
+ )
+ private val masterSkullPattern by patternGroup.pattern(
+ "masterskull",
+ "(.*)Master Skull - Tier ."
+ )
+ private val gardenVacuumPatterm by patternGroup.pattern(
+ "vacuum",
+ "§7Vacuum Bag: §6(?<amount>\\d*) Pests?"
+ )
+ private val harvestPattern by patternGroup.pattern(
+ "harvest",
+ "§7§7You may harvest §6(?<amount>.).*"
+ )
+ private val dungeonPotionPattern by patternGroup.pattern(
+ "dungeonpotion",
+ "Dungeon (?<level>.*) Potion"
+ )
+ private val bingoGoalRankPattern by patternGroup.pattern(
+ "bingogoalrank",
+ "(§.)*You were the (§.)*(?<rank>[\\w]+)(?<ordinal>(st|nd|rd|th)) (§.)*to"
+ )
private val bottleOfJyrre = "NEW_BOTTLE_OF_JYRRE".asInternalName()
@@ -104,8 +120,8 @@ object ItemDisplayOverlayFeatures {
}
if (PET_LEVEL.isSelected()) {
- val chestName = InventoryUtils.openInventoryName()
- if (!chestName.endsWith("Sea Creature Guide") && ItemUtils.isPet(itemName)) {
+ val containerName = InventoryUtils.openInventoryName()
+ if (!containerName.endsWith("Sea Creature Guide") && ItemUtils.isPet(itemName)) {
petLevelPattern.matchMatcher(itemName) {
val rawLevel = group("level")
val level = rawLevel.toIntOrNull()
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 cf3940727..040e215b8 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemStars.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemStars.kt
@@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.features.inventory.ItemDisplayOverlayFeatures.isSel
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.StringUtils.matches
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.event.entity.player.ItemTooltipEvent
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -17,9 +18,13 @@ class ItemStars {
private val config get() = SkyHanniMod.feature.inventory
+ private val starPattern by RepoPattern.pattern(
+ "inventory.itemstars.stars",
+ "(.*)§.✪(.*)"
+ )
+
private val armorNames = mutableListOf<String>()
private val tiers = mutableMapOf<String, Int>()
- private val starFindPattern = "(.*)§.✪(.*)".toPattern()
private val armorParts = listOf("Helmet", "Chestplate", "Leggings", "Boots")
@SubscribeEvent(priority = EventPriority.LOW)
@@ -33,7 +38,7 @@ class ItemStars {
if (stars > 0) {
var name = itemName
- while (starFindPattern.matches(name)) {
+ while (starPattern.matches(name)) {
name = name.replaceFirst("§.✪".toRegex(), "")
}
name = name.trim()
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 2591d1780..bc31e61e4 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/StatsTuning.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/StatsTuning.kt
@@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RenderUtils.highlight
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.item.ItemStack
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -18,7 +19,11 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class StatsTuning {
private val config get() = SkyHanniMod.feature.inventory.statsTuning
- private val patternStatPoints = "§7Stat has: §e(?<amount>\\d+) points?".toPattern()
+
+ private val statPointsPattern by RepoPattern.pattern(
+ "inventory.statstuning.points",
+ "§7Stat has: §e(?<amount>\\d+) points?"
+ )
@SubscribeEvent
fun onRenderItemTip(event: RenderInventoryItemTipEvent) {
@@ -89,7 +94,7 @@ class StatsTuning {
private fun points(stack: ItemStack, event: RenderInventoryItemTipEvent) {
for (line in stack.getLore()) {
- patternStatPoints.matchMatcher(line) {
+ statPointsPattern.matchMatcher(line) {
val points = group("amount")
event.stackTip = points
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/tiarelay/Relay.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/tiarelay/Relay.kt
index 784673ce0..d1305120c 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/tiarelay/Relay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/tiarelay/Relay.kt
@@ -49,6 +49,10 @@ enum class Relay(
"§e[NPC] §dTia the Fairy§f: §b✆ §f§r§fThe next relay is on top of the Auction House."
);
- val chatPattern by RepoPattern.pattern("relay.chat." + relayName.takeWhile { it != ' ' }, chatMessage)
+ val chatPattern by RepoPattern.pattern(
+ "relay.chat." + relayName.takeWhile { it != ' ' },
+ chatMessage
+ )
+
fun checkChatMessage(string: String) = chatPattern.matches(string)
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt
index e0af344c3..2e7a4b8cc 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt
@@ -26,6 +26,7 @@ import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getAbilityScrolls
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getItemId
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getItemUuid
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.client.Minecraft
import net.minecraft.item.ItemStack
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -35,11 +36,19 @@ class ItemAbilityCooldown {
private val config get() = SkyHanniMod.feature.itemAbilities
+ private val patternGroup = RepoPattern.group("item.abilities.cooldown")
+ private val youAlignedOthersPattern by patternGroup.pattern(
+ "alignedother",
+ "§eYou aligned §r§a.* §r§eother player(s)?!"
+ )
+ private val youBuffedYourselfPattern by patternGroup.pattern(
+ "buffedyourself",
+ "§aYou buffed yourself for §r§c\\+\\d+❁ Strength"
+ )
+
private var lastAbility = ""
private var items = mapOf<ItemStack, List<ItemText>>()
private var abilityItems = mapOf<ItemStack, MutableList<ItemAbility>>()
- private val youAlignedOthersPattern = "§eYou aligned §r§a.* §r§eother player(s)?!".toPattern()
- private val youBuffedYourselfPattern = "§aYou buffed yourself for §r§c\\+\\d+❁ Strength".toPattern()
private val WEIRD_TUBA = "WEIRD_TUBA".asInternalName()
private val WEIRDER_TUBA = "WEIRDER_TUBA".asInternalName()
private val VOODOO_DOLL_WILTED = "VOODOO_DOLL_WILTED".asInternalName()
diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt
index 08f4c59e6..5a4bf0f89 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt
@@ -17,6 +17,7 @@ import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.TimeUtils
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import io.github.moulberry.notenoughupdates.util.SkyBlockTime
import net.minecraft.entity.item.EntityArmorStand
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -27,6 +28,11 @@ class KingTalismanHelper {
private val config get() = SkyHanniMod.feature.mining.kingTalisman
private val storage get() = ProfileStorageData.profileSpecific?.mining
+ private val kingPattern by RepoPattern.pattern(
+ "mining.kingtalisman.king",
+ "§6§lKing (?<name>.*)"
+ )
+
companion object {
private var currentOffset: Int? = null
@@ -88,7 +94,7 @@ class KingTalismanHelper {
private fun checkOffset() {
val king = EntityUtils.getEntitiesNearby<EntityArmorStand>(LorenzVec(129.6, 196.0, 196.7), 2.0)
.filter { it.name.startsWith("§6§lKing ") }.firstOrNull() ?: return
- val foundKing = "§6§lKing (?<name>.*)".toPattern().matchMatcher(king.name) {
+ val foundKing = kingPattern.matchMatcher(king.name) {
group("name")
} ?: return
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 3df832563..b5abd78ea 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
@@ -149,7 +149,10 @@ enum class PowderChestReward(val displayName: String, pattern: String) {
GOLD_ESSENCE("§6Gold Essence", "§aYou received §r§6[+](?<amount>.*) Gold Essence§r§a."),
;
- val chatPattern by RepoPattern.pattern("mining.powder.tracker.reward." + this.patternName(), pattern)
+ val chatPattern by RepoPattern.pattern(
+ "mining.powder.tracker.reward." + this.patternName(),
+ pattern
+ )
private fun patternName() = name.lowercase().replace("_", "")
}
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 5b1a9e64b..5f623359e 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt
@@ -66,13 +66,24 @@ class MinionFeatures {
private var lastInventoryClosed = 0L
private var coinsPerDay = ""
- private val minionUpgradePattern by RepoPattern.pattern(
- "minion.chat.upgrade",
+
+ private val patternGroup = RepoPattern.group("minion")
+ private val minionUpgradePattern by patternGroup.pattern(
+ "chat.upgrade",
"§aYou have upgraded your Minion to Tier (?<tier>.*)"
)
- private val minionCoinPattern by RepoPattern.pattern("minion.chat.coin", "§aYou received §r§6(.*) coins§r§a!")
- private val minionTitlePattern by RepoPattern.pattern("minion.title", "Minion [^➜]")
- private val minionCollectItemPattern by RepoPattern.pattern("minion.item.collect", "^§aCollect All$")
+ private val minionCoinPattern by patternGroup.pattern(
+ "chat.coin",
+ "§aYou received §r§6(.*) coins§r§a!"
+ )
+ private val minionTitlePattern by patternGroup.pattern(
+ "title",
+ "Minion [^➜]"
+ )
+ private val minionCollectItemPattern by patternGroup.pattern(
+ "item.collect",
+ "^§aCollect All$"
+ )
@SubscribeEvent
fun onPlayerInteract(event: PlayerInteractEvent) {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/CurrentPetDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/CurrentPetDisplay.kt
index 866242368..76261b5fb 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/CurrentPetDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/CurrentPetDisplay.kt
@@ -12,17 +12,30 @@ import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RenderUtils.renderString
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.matches
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class CurrentPetDisplay {
private val config get() = SkyHanniMod.feature.misc.pets
- // TODO USE SH-REPO
- private val inventorySelectedPetPattern = "§7§7Selected pet: (?<pet>.*)".toPattern()
- private val chatSpawnPattern = "§aYou summoned your §r(?<pet>.*)§r§a!".toPattern()
- private val chatDespawnPattern = "§aYou despawned your §r.*§r§a!".toPattern()
- private val chatPetRulePattern = "§cAutopet §eequipped your §7\\[Lvl .*] (?<pet>.*)! §a§lVIEW RULE".toPattern()
+ private val patternGroup = RepoPattern.group("misc.currentpet")
+ private val inventorySelectedPetPattern by patternGroup.pattern(
+ "inventory.selected",
+ "§7§7Selected pet: (?<pet>.*)"
+ )
+ private val chatSpawnPattern by patternGroup.pattern(
+ "chat.spawn",
+ "§aYou summoned your §r(?<pet>.*)§r§a!"
+ )
+ private val chatDespawnPattern by patternGroup.pattern(
+ "chat.despawn",
+ "§aYou despawned your §r.*§r§a!"
+ )
+ private val chatPetRulePattern by patternGroup.pattern(
+ "chat.rule",
+ "§cAutopet §eequipped your §7\\[Lvl .*] (?<pet>.*)! §a§lVIEW RULE"
+ )
@SubscribeEvent
fun onChat(event: LorenzChatEvent) {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/InGameDateDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/InGameDateDisplay.kt
index ff4f4facf..7db11478c 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/InGameDateDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/InGameDateDisplay.kt
@@ -11,14 +11,18 @@ import at.hannibal2.skyhanni.utils.RenderUtils.renderString
import at.hannibal2.skyhanni.utils.StringUtils.matches
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.TimeUtils.formatted
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import io.github.moulberry.notenoughupdates.util.SkyBlockTime
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class InGameDateDisplay {
private val config get() = SkyHanniMod.feature.gui.inGameDate
- private val monthAndDatePattern =
- ".*((Early|Late) )?(Winter|Spring|Summer|Autumn) [0-9]{1,2}(nd|rd|th|st)?.*".toPattern()
+
+ private val monthAndDatePattern by RepoPattern.pattern(
+ "misc.ingametime.date",
+ ".*((Early|Late) )?(Winter|Spring|Summer|Autumn) [0-9]{1,2}(nd|rd|th|st)?.*"
+ )
private var display = ""
// sun, moon, spooky
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 5ee6103a2..fbb606229 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt
@@ -23,6 +23,7 @@ import at.hannibal2.skyhanni.utils.TimeUnit
import at.hannibal2.skyhanni.utils.TimeUtils
import at.hannibal2.skyhanni.utils.TimeUtils.timerColor
import at.hannibal2.skyhanni.utils.Timer
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.network.play.server.S47PacketPlayerListHeaderFooter
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -70,8 +71,10 @@ class NonGodPotEffectDisplay {
;
}
- // TODO USE SH-REPO
- private var patternEffectsCount = "§7You have §e(?<name>\\d+) §7non-god effects\\.".toPattern()
+ private val effectsCountPattern by RepoPattern.pattern(
+ "misc.nongodpot.effects",
+ "§7You have §e(?<name>\\d+) §7non-god effects\\."
+ )
private var totalEffectsCount = 0
@SubscribeEvent
@@ -237,7 +240,7 @@ class NonGodPotEffectDisplay {
}
}
}
- patternEffectsCount.matchMatcher(line) {
+ effectsCountPattern.matchMatcher(line) {
val group = group("name")
effectsCount = group.toInt()
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PatcherSendCoordinates.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PatcherSendCoordinates.kt
index d9b876546..a06304213 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/PatcherSendCoordinates.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PatcherSendCoordinates.kt
@@ -14,6 +14,7 @@ import at.hannibal2.skyhanni.utils.RenderUtils.drawColor
import at.hannibal2.skyhanni.utils.RenderUtils.drawString
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.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -22,15 +23,17 @@ class PatcherSendCoordinates {
private val patcherBeacon = mutableListOf<PatcherBeacon>()
private val logger = LorenzLogger("misc/patchercoords")
- // TODO USE SH-REPO
- private val pattern = "(?<playerName>.*): [xX]: (?<x>[0-9.-]+),? [yY]: (?<y>[0-9.-]+),? [zZ]: (?<z>.*)".toPattern()
+ private val coordinatePattern by RepoPattern.pattern(
+ "misc.patchercoords.coords",
+ "(?<playerName>.*): [xX]: (?<x>[0-9.-]+),? [yY]: (?<y>[0-9.-]+),? [zZ]: (?<z>.*)"
+ )
@SubscribeEvent
fun onPatcherCoordinates(event: LorenzChatEvent) {
if (!SkyHanniMod.feature.misc.patcherSendCoordWaypoint) return
val message = event.message.removeColor()
- pattern.matchMatcher(message) {
+ coordinatePattern.matchMatcher(message) {
var description = group("playerName").split(" ").last()
val x = group("x").toFloat()
val y = group("y").toFloat()
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PlayerChatSymbols.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PlayerChatSymbols.kt
index 79cc77234..9492df47b 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/PlayerChatSymbols.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PlayerChatSymbols.kt
@@ -13,6 +13,7 @@ import at.hannibal2.skyhanni.utils.StringUtils.getPlayerNameAndRankFromChatMessa
import at.hannibal2.skyhanni.utils.StringUtils.getPlayerNameFromChatMessage
import at.hannibal2.skyhanni.utils.StringUtils.removeResets
import at.hannibal2.skyhanni.utils.TabListData
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.util.ChatComponentText
import net.minecraft.util.IChatComponent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -22,8 +23,16 @@ class PlayerChatSymbols {
private val config get() = SkyHanniMod.feature.chat.chatSymbols
private val nameSymbols = mutableMapOf<String, String>()
- private val symbolsPattern = "^(?<symbols>(?:(?:§\\w)+\\S)+) ".toPattern()
- private val symbolPattern = "((?:§\\w)+\\S)".toPattern()
+
+ private val patternGroup = RepoPattern.group("misc.chatsymbols")
+ private val symbolsPattern by patternGroup.pattern(
+ "symbols",
+ "^(?<symbols>(?:(?:§\\w)+\\S)+) "
+ )
+ private val symbolPattern by patternGroup.pattern(
+ "symbol",
+ "((?:§\\w)+\\S)"
+ )
@SubscribeEvent
fun onChatReceived(event: LorenzChatEvent) {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ServerRestartTitle.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ServerRestartTitle.kt
index fb228418e..fc83bdfb4 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/ServerRestartTitle.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ServerRestartTitle.kt
@@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.TimeUtils
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.time.Duration.Companion.seconds
@@ -13,8 +14,10 @@ class ServerRestartTitle {
private val config get() = SkyHanniMod.feature.misc
- // TODO USE SH-REPO
- private val pattern = "§cServer closing: (?<minutes>\\d+):(?<seconds>\\d+) §8.*".toPattern()
+ private val restartPattern by RepoPattern.pattern(
+ "misc.serverrestart.restart",
+ "§cServer closing: (?<minutes>\\d+):(?<seconds>\\d+) §8.*"
+ )
@SubscribeEvent
fun onTick(event: LorenzTickEvent) {
@@ -24,7 +27,7 @@ class ServerRestartTitle {
if (!event.repeatSeconds(1)) return
for (line in ScoreboardData.sidebarLinesFormatted) {
- pattern.matchMatcher(line) {
+ restartPattern.matchMatcher(line) {
val minutes = group("minutes").toInt()
val seconds = group("seconds").toInt()
val totalSeconds = minutes * 60 + seconds
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt
index b28f74e52..a68c9d728 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt
@@ -20,6 +20,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.TimeLimitedCache
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.random.Random
import kotlin.time.Duration.Companion.minutes
@@ -28,8 +29,10 @@ object AdvancedPlayerList {
private val config get() = SkyHanniMod.feature.misc.compactTabList.advancedPlayerList
- // TODO USE SH-REPO
- private val pattern = ".*\\[(?<level>.*)] §r(?<name>.*)".toPattern()
+ private val levelPattern by RepoPattern.pattern(
+ "misc.compacttablist.advanced.level",
+ ".*\\[(?<level>.*)] §r(?<name>.*)"
+ )
private var playerDatas = mutableMapOf<String, PlayerData>()
@@ -57,7 +60,7 @@ object AdvancedPlayerList {
extraTitles++
continue
}
- pattern.matchMatcher(line) {
+ levelPattern.matchMatcher(line) {
val levelText = group("level")
val removeColor = levelText.removeColor()
try {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListReader.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListReader.kt
index cb0d3c6c8..659d49e20 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListReader.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListReader.kt
@@ -4,9 +4,11 @@ import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.mixins.transformers.AccessorGuiPlayerTabOverlay
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.StringUtils.removeResets
import at.hannibal2.skyhanni.utils.StringUtils.trimWhiteSpaceAndResets
import at.hannibal2.skyhanni.utils.TabListData
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.client.Minecraft
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -15,15 +17,37 @@ object TabListReader {
private val config get() = SkyHanniMod.feature.misc.compactTabList
- // TODO USE SH-REPO
+ private val patternGroup = RepoPattern.group("misc.compacttablist")
+ val usernamePattern by patternGroup.pattern(
+ "username",
+ "^\\[(?<sblevel>\\d+)] (?:\\[\\w+] )?(?<username>\\w+)"
+ )
+ private val godPotPattern by patternGroup.pattern(
+ "effects.godpot",
+ "You have a God Potion active! (?<timer>[\\w ]+)"
+ )
+ private val activeEffectPattern by patternGroup.pattern(
+ "effects.active",
+ "Active Effects(?:§.)*(?:\\n(?:§.)*§7.+)*"
+ )
+ private val effectCountPattern by patternGroup.pattern(
+ "effects.count",
+ "You have (?<effectCount>[0-9]+) active effect"
+ )
+ private val cookiePattern by patternGroup.pattern(
+ "cookie",
+ "Cookie Buff(?:§.)*(?:\\n(§.)*§7.+)*"
+ )
+ private val dungeonBuffPattern by patternGroup.pattern(
+ "dungeonbuff",
+ "Dungeon Buffs(?:§.)*(?:\\n(§.)*§7.+)*"
+ )
+ private val upgradesPattern by patternGroup.pattern(
+ "upgrades",
+ "(?<firstPart>§e[A-Za-z ]+)(?<secondPart> §f[\\w ]+)"
+ )
+
var hypixelAdvertisingString = "HYPIXEL.NET"
- private val godPotPattern = "You have a God Potion active! (?<timer>[\\w ]+)".toPattern()
- private val activeEffectPattern = "Active Effects(?:§.)*(?:\\n(?:§.)*§7.+)*".toPattern()
- private val effectCountPattern = "You have (?<effectCount>[0-9]+) active effect".toPattern()
- private val cookiePattern = "Cookie Buff(?:§.)*(?:\\n(§.)*§7.+)*".toPattern()
- private val dungeonBuffPattern = "Dungeon Buffs(?:§.)*(?:\\n(§.)*§7.+)*".toPattern()
- private val upgradesPattern = "(?<firstPart>§e[A-Za-z ]+)(?<secondPart> §f[\\w ]+)".toPattern()
- private val tabListSPattern = "(?i)§S".toPattern()
val renderColumns = mutableListOf<RenderColumn>()
@@ -83,7 +107,7 @@ object TabListReader {
val column = TabColumn("§2§lOther")
- var footer = tabListSPattern.matcher(tabList.footer_skyhanni.formattedText).replaceAll("")
+ var footer = tabList.footer_skyhanni.formattedText.removeColor()
var matcher = godPotPattern.matcher(tabList.footer_skyhanni.unformattedText)
if (matcher.find()) {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListRenderer.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListRenderer.kt
index 76200f835..bff4f3a42 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListRenderer.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListRenderer.kt
@@ -175,7 +175,10 @@ object TabListRenderer {
}
}
- private val fireSalePattern by RepoPattern.pattern("tablist.firesaletitle", "§b§lFire Sales: §r§f\\([0-9]+\\)")
+ private val fireSalePattern by RepoPattern.pattern(
+ "tablist.firesaletitle",
+ "§b§lFire Sales: §r§f\\([0-9]+\\)"
+ )
@SubscribeEvent
fun hideFireFromTheTabListBecauseWhoWantsThose(event: SkipTabListLineEvent) {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabStringType.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabStringType.kt
index 159214b0e..b6b5c36ab 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabStringType.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabStringType.kt
@@ -10,15 +10,12 @@ enum class TabStringType {
companion object {
- // TODO USE SH-REPO
- private val usernamePattern = "^\\[(?<sblevel>\\d+)] (?:\\[\\w+] )?(?<username>\\w+)".toPattern()
-
fun fromLine(line: String): TabStringType {
val strippedLine: String = line.removeColor()
if (strippedLine.startsWith(" ")) {
return TEXT
}
- return if (usernamePattern.matcher(strippedLine).find()) {
+ return if (TabListReader.usernamePattern.matcher(strippedLine).find()) {
PLAYER
} else {
SUB_TITLE
@@ -26,7 +23,7 @@ enum class TabStringType {
}
fun usernameFromLine(input: String): String {
- val usernameMatcher = usernamePattern.matcher(input.removeColor())
+ val usernameMatcher = TabListReader.usernamePattern.matcher(input.removeColor())
return if (usernameMatcher.find()) usernameMatcher.group("username") else input
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/teleportpad/TeleportPadCompactName.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/teleportpad/TeleportPadCompactName.kt
index 777244d6e..7c0745a40 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/teleportpad/TeleportPadCompactName.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/teleportpad/TeleportPadCompactName.kt
@@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.item.EntityArmorStand
import net.minecraftforge.client.event.RenderLivingEvent
@@ -11,10 +12,15 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class TeleportPadCompactName {
-
- // TODO USE SH-REPO
- private val patternName = "§.✦ §aWarp To (?<name>.*)".toPattern()
- private val patternNoName = "§.✦ §cNo Destination".toPattern()
+ private val patternGroup = RepoPattern.group("misc.teleportpad")
+ private val namePattern by patternGroup.pattern(
+ "name",
+ "§.✦ §aWarp To (?<name>.*)"
+ )
+ private val noNamePattern by patternGroup.pattern(
+ "noname",
+ "§.✦ §cNo Destination"
+ )
@SubscribeEvent(priority = EventPriority.HIGH)
fun onRenderLivingB(event: RenderLivingEvent.Specials.Pre<EntityLivingBase>) {
@@ -25,11 +31,11 @@ class TeleportPadCompactName {
val name = entity.name
- patternNoName.matchMatcher(name) {
+ noNamePattern.matchMatcher(name) {
event.isCanceled = true
}
- patternName.matchMatcher(name) {
+ namePattern.matchMatcher(name) {
entity.customNameTag = group("name")
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/teleportpad/TeleportPadInventoryNumber.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/teleportpad/TeleportPadInventoryNumber.kt
index 4530f0406..dd2ddd91d 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/teleportpad/TeleportPadInventoryNumber.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/teleportpad/TeleportPadInventoryNumber.kt
@@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.RenderInventoryItemTipEvent
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class TeleportPadInventoryNumber {
@@ -61,8 +62,10 @@ class TeleportPadInventoryNumber {
private var inTeleportPad = false
- // TODO USE SH-REPO
- private val pattern = "§.(?<number>.*) teleport pad".toPattern()
+ private val padNumberPattern by RepoPattern.pattern(
+ "misc.teleportpad.number",
+ "§.(?<number>.*) teleport pad"
+ )
@SubscribeEvent
fun onInventoryOpen(event: InventoryFullyOpenedEvent) {
@@ -77,7 +80,7 @@ class TeleportPadInventoryNumber {
val name = event.stack.name?.lowercase() ?: return
- pattern.matchMatcher(name) {
+ padNumberPattern.matchMatcher(name) {
val text = group("number")
numbers[text]?.let {
event.stackTip = "$it"
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt
index 022d7eeb3..05d621f61 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt
@@ -33,6 +33,7 @@ import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.TabListData
import at.hannibal2.skyhanni.utils.getLorenzVec
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.client.Minecraft
import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.item.EntityArmorStand
@@ -43,15 +44,23 @@ import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.Duration.Companion.seconds
object TrevorFeatures {
-
- // TODO USE SH-REPO
- private val trapperPattern =
- "\\[NPC] Trevor: You can find your (?<rarity>.*) animal near the (?<location>.*).".toPattern()
- private val talbotPatternAbove =
- "The target is around (?<height>.*) blocks above, at a (?<angle>.*) degrees angle!".toPattern()
- private val talbotPatternBelow =
- "The target is around (?<height>.*) blocks below, at a (?<angle>.*) degrees angle!".toPattern()
- private val locationPattern = "Zone: (?<zone>.*)".toPattern()
+ private val patternGroup = RepoPattern.group("misc.trevor")
+ private val trapperPattern by patternGroup.pattern(
+ "trapper",
+ "\\[NPC] Trevor: You can find your (?<rarity>.*) animal near the (?<location>.*)."
+ )
+ private val talbotPatternAbove by patternGroup.pattern(
+ "above",
+ "The target is around (?<height>.*) blocks above, at a (?<angle>.*) degrees angle!"
+ )
+ private val talbotPatternBelow by patternGroup.pattern(
+ "below",
+ "The target is around (?<height>.*) blocks below, at a (?<angle>.*) degrees angle!"
+ )
+ private val locationPattern by patternGroup.pattern(
+ "zone",
+ "Zone: (?<zone>.*)"
+ )
private var timeUntilNextReady = 0
private var trapperReady: Boolean = true
@@ -89,6 +98,9 @@ object TrevorFeatures {
@SubscribeEvent
fun onChat(event: LorenzChatEvent) {
if (!onFarmingIsland()) return
+
+ val formattedMessage = event.message.removeColor()
+
if (event.message == "§aReturn to the Trapper soon to get a new animal to hunt!") {
TrevorSolver.resetLocation()
if (config.trapperMobDiedMessage) {
@@ -107,30 +119,26 @@ object TrevorFeatures {
TrevorSolver.mobLocation = CurrentMobArea.NONE
}
- var matcher = trapperPattern.matcher(event.message.removeColor())
- if (matcher.matches()) {
+ trapperPattern.matchMatcher(formattedMessage) {
timeUntilNextReady = if (GardenCropSpeed.finneganPerkActive()) 16 else 21
currentStatus = TrapperStatus.ACTIVE
currentLabel = "§cActive Quest"
trapperReady = false
- TrevorTracker.startQuest(matcher)
+ TrevorTracker.startQuest(this)
updateTrapper()
lastChatPromptTime = SimpleTimeMark.farPast()
}
- matcher = talbotPatternAbove.matcher(event.message.removeColor())
- if (matcher.matches()) {
- val height = matcher.group("height").toInt()
+ talbotPatternAbove.matchMatcher(formattedMessage) {
+ val height = group("height").toInt()
TrevorSolver.findMobHeight(height, true)
}
-
- matcher = talbotPatternBelow.matcher(event.message.removeColor())
- if (matcher.matches()) {
- val height = matcher.group("height").toInt()
+ talbotPatternBelow.matchMatcher(formattedMessage) {
+ val height = group("height").toInt()
TrevorSolver.findMobHeight(height, false)
}
- if (event.message.removeColor() == "[NPC] Trevor: You will have 10 minutes to find the mob from when you accept the task.") {
+ if (formattedMessage == "[NPC] Trevor: You will have 10 minutes to find the mob from when you accept the task.") {
teleportBlock = SimpleTimeMark.now()
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorTracker.kt
index 37cec25fa..60c28e1b6 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorTracker.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorTracker.kt
@@ -10,6 +10,8 @@ import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList
import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
+import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.util.regex.Matcher
@@ -17,10 +19,15 @@ object TrevorTracker {
private val config get() = SkyHanniMod.feature.misc.trevorTheTrapper
- // TODO USE SH-REPO
- private val selfKillMobPattern =
- "§aYour mob died randomly, you are rewarded §r§5(?<pelts>.*) pelts§r§a.".toPattern()
- private val killMobPattern = "§aKilling the animal rewarded you §r§5(?<pelts>.*) pelts§r§a.".toPattern()
+ private val patternGroup = RepoPattern.group("misc.trevor")
+ private val selfKillMobPattern by patternGroup.pattern(
+ "selfkill",
+ "§aYour mob died randomly, you are rewarded §r§5(?<pelts>.*) pelts§r§a."
+ )
+ private val killMobPattern by patternGroup.pattern(
+ "kill",
+ "§aKilling the animal rewarded you §r§5(?<pelts>.*) pelts§r§a."
+ )
private var display = emptyList<List<Any>>()
@@ -76,16 +83,15 @@ object TrevorTracker {
if (!TrevorFeatures.onFarmingIsland()) return
val storage = ProfileStorageData.profileSpecific?.trapperData ?: return
- var matcher = selfKillMobPattern.matcher(event.message)
- if (matcher.matches()) {
- val pelts = matcher.group("pelts").toInt()
+ selfKillMobPattern.matchMatcher(event.message) {
+ val pelts = group("pelts").toInt()
storage.peltsGained += pelts
storage.selfKillingAnimals += 1
update()
}
- matcher = killMobPattern.matcher(event.message)
- if (matcher.matches()) {
- val pelts = matcher.group("pelts").toInt()
+
+ killMobPattern.matchMatcher(event.message) {
+ val pelts = group("pelts").toInt()
storage.peltsGained += pelts
storage.killedAnimals += 1
update()
@@ -125,7 +131,7 @@ object TrevorTracker {
@SubscribeEvent
fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) {
if (!shouldDisplay()) return
- config.position.renderStringsAndItems(display, posLabel = "Frozen Treasure Tracker")
+ config.position.renderStringsAndItems(display, posLabel = "Trevor Tracker")
}
private fun shouldDisplay(): Boolean {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangFreezeCooldown.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangFreezeCooldown.kt
index b82cf1cc3..cb012f728 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangFreezeCooldown.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangFreezeCooldown.kt
@@ -10,6 +10,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RenderUtils.renderString
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import at.hannibal2.skyhanni.utils.TimeUtils.format
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.time.Duration.Companion.seconds
@@ -18,8 +19,10 @@ object AshfangFreezeCooldown {
private val config get() = SkyHanniMod.feature.crimsonIsle.ashfang
- // TODO USE SH-REPO
- private val cryogenicBlastPattern = "§cAshfang Follower's Cryogenic Blast hit you for (.*) damage!".toPattern()
+ private val cryogenicBlastPattern by RepoPattern.pattern(
+ "ashfang.freeze.cryogenic",
+ "§cAshfang Follower's Cryogenic Blast hit you for .* damage!"
+ )
private var lastHit = SimpleTimeMark.farPast()
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/stillgorechateau/RiftBloodEffigies.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/stillgorechateau/RiftBloodEffigies.kt
index a85c92237..cd18de35a 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/stillgorechateau/RiftBloodEffigies.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/stillgorechateau/RiftBloodEffigies.kt
@@ -20,12 +20,24 @@ import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.TimeUtils
import at.hannibal2.skyhanni.utils.getLorenzVec
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.entity.item.EntityArmorStand
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class RiftBloodEffigies {
private val config get() = RiftAPI.config.area.stillgoreChateau.bloodEffigies
+
+ private val patternGroup = RepoPattern.group("rift.area.stillgore.effegies")
+ private val effigiesTimerPattern by patternGroup.pattern(
+ "respawn",
+ "§eRespawn §c(?<time>.*) §7\\(or click!\\)"
+ )
+ private val effegieHeartPattern by patternGroup.pattern(
+ "heart",
+ "Effigies: (?<hearts>.*)"
+ )
+
private var locations: List<LorenzVec> = emptyList()
private var effigiesTimes = mapOf(
0 to -1L,
@@ -36,9 +48,6 @@ class RiftBloodEffigies {
5 to -1L,
)
- // TODO USE SH-REPO
- private val effigiesTimerPattern = "§eRespawn §c(?<time>.*) §7\\(or click!\\)".toPattern()
-
@SubscribeEvent
fun onWorldChange(event: LorenzWorldChangeEvent) {
effigiesTimes = mapOf(
@@ -65,7 +74,7 @@ class RiftBloodEffigies {
if (!isEnabled()) return
val line = event.newList.firstOrNull { it.startsWith("Effigies:") } ?: return
- val hearts = "Effigies: (?<hearts>.*)".toPattern().matchMatcher(line) {
+ val hearts = effegieHeartPattern.matchMatcher(line) {
group("hearts")
} ?: return
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminTracker.kt
index 89a500c2c..cf6d0e3e1 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminTracker.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminTracker.kt
@@ -26,12 +26,28 @@ import java.util.regex.Pattern
object VerminTracker {
- private val group = RepoPattern.group("rift.area.westvillage.vermintracker")
- private val silverfishPattern by group.pattern("silverfish", ".*§eYou vacuumed a §.*Silverfish.*")
- private val spiderPattern by group.pattern("spider", ".*§eYou vacuumed a §.*Spider.*")
- private val flyPattern by group.pattern("fly", ".*§eYou vacuumed a §.*Fly.*")
- private val verminBinPattern by group.pattern("binline", "§fVermin Bin: §\\w(?<count>\\d+) (?<vermin>\\w+)")
- private val verminBagPattern by group.pattern("bagline", "§fVacuum Bag: §\\w(?<count>\\d+) (?<vermin>\\w+)")
+ private val patternGroup = RepoPattern.group("rift.area.westvillage.vermintracker")
+ private val silverfishPattern by patternGroup.pattern(
+ "silverfish",
+ ".*§eYou vacuumed a §.*Silverfish.*"
+ )
+ private val spiderPattern by patternGroup.pattern(
+ "spider",
+ ".*§eYou vacuumed a §.*Spider.*"
+ )
+ private val flyPattern by patternGroup.pattern(
+ "fly",
+ ".*§eYou vacuumed a §.*Fly.*"
+ )
+ private val verminBinPattern by patternGroup.pattern(
+ "binline",
+ "§fVermin Bin: §\\w(?<count>\\d+) (?<vermin>\\w+)"
+ )
+ private val verminBagPattern by patternGroup.pattern(
+ "bagline",
+ "§fVacuum Bag: §\\w(?<count>\\d+) (?<vermin>\\w+)"
+ )
+
private var hasVacuum = false
private val TURBOMAX_VACUUM = "TURBOMAX_VACUUM".asInternalName()
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/kloon/KloonHacking.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/kloon/KloonHacking.kt
index 35ab292e4..4ecfa459c 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/kloon/KloonHacking.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/kloon/KloonHacking.kt
@@ -19,6 +19,7 @@ import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.RenderUtils.highlight
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import io.github.moulberry.notenoughupdates.events.SlotClickEvent
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -27,8 +28,10 @@ class KloonHacking {
private val config get() = RiftAPI.config.area.westVillage.hacking
- // TODO USE SH-REPO
- val pattern = "You've set the color of this terminal to (?<colour>.*)!".toPattern()
+ private val colourPattern by RepoPattern.pattern(
+ "rift.area.westvillage.kloon.colour",
+ "You've set the color of this terminal to (?<colour>.*)!"
+ )
private var wearingHelmet = false
private var inTerminalInventory = false
@@ -129,7 +132,7 @@ class KloonHacking {
fun onChat(event: LorenzChatEvent) {
if (!RiftAPI.inRift()) return
if (!wearingHelmet) return
- pattern.matchMatcher(event.message.removeColor()) {
+ colourPattern.matchMatcher(event.message.removeColor()) {
val storage = ProfileStorageData.profileSpecific?.rift ?: return
val colour = group("colour")
val completedTerminal = KloonTerminal.entries.firstOrNull { it.name == colour } ?: return
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/CruxTalismanDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/CruxTalismanDisplay.kt
index 37aae74b6..a38de4fd3 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/CruxTalismanDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/CruxTalismanDisplay.kt
@@ -14,15 +14,17 @@ import at.hannibal2.skyhanni.utils.NumberUtil.roundToPrecision
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
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
object CruxTalismanDisplay {
private val config get() = RiftAPI.config.cruxTalisman
- // TODO USE SH-REPO
- private val progressPattern =
- ".*(?<tier>§[0-9a-z][IV1-4-]+)\\s+(?<name>§[0-9a-z]\\w+)§[0-9a-z]:\\s*(?<progress>§[0-9a-z](?:§[0-9a-z])?MAXED|§[0-9a-z]\\d+§[0-9a-z]/§[0-9a-z]\\d+).*".toPattern()
+ private val progressPattern by RepoPattern.pattern(
+ "rift.everywhere.crux.progress",
+ ".*(?<tier>§[0-9a-z][IV1-4-]+)\\s+(?<name>§[0-9a-z]\\w+)§[0-9a-z]:\\s*(?<progress>§[0-9a-z](?:§[0-9a-z])?MAXED|§[0-9a-z]\\d+§[0-9a-z]/§[0-9a-z]\\d+).*"
+ )
private val partialName = "CRUX_TALISMAN"
private var display = emptyList<List<Any>>()
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftTimer.kt
index 870ba3f9f..e7f8ad5a1 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftTimer.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftTimer.kt
@@ -10,14 +10,17 @@ import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.TimeUtils
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class RiftTimer {
private val config get() = RiftAPI.config.timer
- // TODO USE SH-REPO
- val pattern = "§(?<color>[a7])(?<time>.*)ф Left.*".toPattern()
+ private val timePattern by RepoPattern.pattern(
+ "rift.everywhere.timer",
+ "§(?<color>[a7])(?<time>.*)ф Left.*"
+ )
private var display = emptyList<String>()
private var maxTime = 0L
@@ -37,7 +40,7 @@ class RiftTimer {
fun onActionBar(event: LorenzActionBarEvent) {
if (!isEnabled()) return
for (entry in event.message.split(" ")) {
- pattern.matchMatcher(entry) {
+ timePattern.matchMatcher(entry) {
val color = group("color")
val newTime = getTime(group("time"))
if (color == "7") {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/RiftMotesOrb.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/RiftMotesOrb.kt
index e0f5f6ee9..1fa1c700e 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/RiftMotesOrb.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/RiftMotesOrb.kt
@@ -13,6 +13,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.util.EnumParticleTypes
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -20,8 +21,10 @@ class RiftMotesOrb {
private val config get() = RiftAPI.config.motesOrbs
- // TODO USE SH-REPO
- private val pattern = "§5§lORB! §r§dPicked up §r§5+.* Motes§r§d.*".toPattern()
+ private val motesPattern by RepoPattern.pattern(
+ "rift.everywhere.motesorb",
+ "§5§lORB! §r§dPicked up §r§5+.* Motes§r§d.*"
+ )
private var motesOrbs = emptyList<MotesOrb>()
@@ -56,8 +59,8 @@ class RiftMotesOrb {
}
@SubscribeEvent
- fun onChat(event: LorenzChatEvent) {
- pattern.matchMatcher(event.message) {
+ fun onChatMessage(event: LorenzChatEvent) {
+ motesPattern.matchMatcher(event.message) {
motesOrbs.minByOrNull { it.location.distanceToPlayer() }?.let {
it.pickedUp = true
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/ShowMotesNpcSellPrice.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/ShowMotesNpcSellPrice.kt
index 89297ad05..bf14e2277 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/ShowMotesNpcSellPrice.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/ShowMotesNpcSellPrice.kt
@@ -26,6 +26,7 @@ import at.hannibal2.skyhanni.utils.RenderUtils.highlight
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.renderables.Renderable
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -33,8 +34,10 @@ class ShowMotesNpcSellPrice {
private val config get() = RiftAPI.config.motes
- // TODO USE SH-REPO
- private val pattern = ".*(?:§\\w)+You have (?:§\\w)+(?<amount>\\d) Grubber Stacks.*".toPattern()
+ private val burgerPattern by RepoPattern.pattern(
+ "rift.everywhere.burger",
+ ".*(?:§\\w)+You have (?:§\\w)+(?<amount>\\d) Grubber Stacks.*"
+ )
private var display = emptyList<List<Any>>()
private val itemMap = mutableMapOf<NEUInternalName, Pair<MutableList<Int>, Double>>()
@@ -132,7 +135,7 @@ class ShowMotesNpcSellPrice {
@SubscribeEvent
fun onChat(event: LorenzChatEvent) {
if (!RiftAPI.inRift()) return
- pattern.matchMatcher(event.message) {
+ burgerPattern.matchMatcher(event.message) {
config.burgerStacks = group("amount").toInt()
chat("Set your McGrubber's burger stacks to ${group("amount")}.")
}
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 = ""
diff --git a/src/main/java/at/hannibal2/skyhanni/features/stranded/HighlightPlaceableNpcs.kt b/src/main/java/at/hannibal2/skyhanni/features/stranded/HighlightPlaceableNpcs.kt
index 4a0eb7049..75cadeef5 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/stranded/HighlightPlaceableNpcs.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/stranded/HighlightPlaceableNpcs.kt
@@ -10,13 +10,18 @@ import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RenderUtils.highlight
import at.hannibal2.skyhanni.utils.StringUtils.matches
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class HighlightPlaceableNpcs {
private val config get() = SkyHanniMod.feature.stranded
- private val locationPattern = "§7Location: §f\\[§e\\d+§f, §e\\d+§f, §e\\d+§f]".toPattern()
+
+ private val locationPattern by RepoPattern.pattern(
+ "stranded.highlightplacement.location",
+ "§7Location: §f\\[§e\\d+§f, §e\\d+§f, §e\\d+§f]"
+ )
private var inInventory = false
private var highlightedItems = emptyList<Int>()
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 06bb39d28..dc971cd5b 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt
@@ -19,6 +19,7 @@ import at.hannibal2.skyhanni.utils.NumberUtil
import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.getLorenzVec
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.entity.EntityLiving
import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.item.EntityArmorStand
@@ -36,16 +37,23 @@ class SummoningMobManager {
private var searchArmorStands = false
private var searchMobs = false
- // TODO repo
- //§aYou have spawned your Tank Zombie §r§asoul! §r§d(249 Mana)
- private val spawnPattern = "§aYou have spawned your (.+) §r§asoul! §r§d\\((\\d+) Mana\\)".toPattern()
- private val despawnPattern = "§cYou have despawned your (monster|monsters)!".toPattern()
-
- //§a§ohannibal2's Tank Zombie§r §a160k§c❤
- private val healthPattern = "§a§o(.+)'s (.+)§r §[ae]([\\dkm]+)§c❤".toPattern()
-
- //§cThe Seraph recalled your 3 summoned allies!
- private val seraphRecallPattern = "§cThe Seraph recalled your (\\d) summoned allies!".toPattern()
+ private val patternGroup = RepoPattern.group("summoning.mobs")
+ private val spawnPattern by patternGroup.pattern( //§aYou have spawned your Tank Zombie §r§asoul! §r§d(249 Mana)
+ "spawn",
+ "§aYou have spawned your (.+) §r§asoul! §r§d\\((\\d+) Mana\\)"
+ )
+ private val despawnPattern by patternGroup.pattern(
+ "despawn",
+ "§cYou have despawned your (monster|monsters)!"
+ )
+ private val healthPattern by patternGroup.pattern( //§a§ohannibal2's Tank Zombie§r §a160k§c❤
+ "health",
+ "§a§o(.+)'s (.+)§r §[ae]([\\dkm]+)§c❤"
+ )
+ private val seraphRecallPattern by patternGroup.pattern( //§cThe Seraph recalled your 3 summoned allies!
+ "seraphrecall",
+ "§cThe Seraph recalled your (\\d) summoned allies!"
+ )
@SubscribeEvent
fun onChat(event: LorenzChatEvent) {
diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiIngameHook.kt b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiIngameHook.kt
index 6399c3e2b..9d1e7ab87 100644
--- a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiIngameHook.kt
+++ b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiIngameHook.kt
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.mixins.hooks
import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.data.PurseAPI
import at.hannibal2.skyhanni.features.garden.GardenAPI
import at.hannibal2.skyhanni.features.garden.GardenPlotAPI
import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.isBarn
@@ -8,9 +9,6 @@ import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.name
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import net.minecraft.client.gui.FontRenderer
-// TODO USE SH-REPO
-private val piggyPattern = "Piggy: (?<coins>.*)".toPattern()
-
fun drawString(
instance: FontRenderer,
text: String,
@@ -26,7 +24,7 @@ private fun replaceString(text: String): String? {
return null
}
if (SkyHanniMod.feature.misc.hidePiggyScoreboard) {
- piggyPattern.matchMatcher(text) {
+ PurseAPI.piggyPattern.matchMatcher(text) {
val coins = group("coins")
return "Purse: $coins"
}
diff --git a/src/main/java/at/hannibal2/skyhanni/test/TestCopyBestiaryValues.kt b/src/main/java/at/hannibal2/skyhanni/test/TestCopyBestiaryValues.kt
index e418f6043..348d05cb2 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/TestCopyBestiaryValues.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/TestCopyBestiaryValues.kt
@@ -12,6 +12,7 @@ import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber
import at.hannibal2.skyhanni.utils.OSUtils
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import com.google.gson.GsonBuilder
import com.google.gson.annotations.Expose
import net.minecraft.item.ItemStack
@@ -41,7 +42,10 @@ object TestCopyBestiaryValues {
var bracket: Int = 0
}
- val pattern = "\\[Lv(?<lvl>.*)] (?<text>.*)".toPattern()
+ private val bestiaryTypePattern by RepoPattern.pattern(
+ "test.bestiary.type",
+ "\\[Lv(?<lvl>.*)] (?<text>.*)"
+ )
@SubscribeEvent(priority = EventPriority.LOW)
fun onLateInventoryOpen(event: InventoryUpdatedEvent) {
@@ -85,7 +89,7 @@ object TestCopyBestiaryValues {
for (i in 10..43) {
val stack = inventoryItems[i] ?: continue
val stackName = stack.name ?: continue
- pattern.matchMatcher(stackName.removeColor()) {
+ bestiaryTypePattern.matchMatcher(stackName.removeColor()) {
val lvl = group("lvl").toInt()
var text = group("text").lowercase().replace(" ", "_")
diff --git a/src/main/java/at/hannibal2/skyhanni/test/TestCopyRngMeterValues.kt b/src/main/java/at/hannibal2/skyhanni/test/TestCopyRngMeterValues.kt
index 5ab1effb7..9d2c0d3d4 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/TestCopyRngMeterValues.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/TestCopyRngMeterValues.kt
@@ -11,17 +11,26 @@ import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber
import at.hannibal2.skyhanni.utils.OSUtils
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
object TestCopyRngMeterValues {
+ private val patternGroup = RepoPattern.group("test.dev.copyrng")
+ private val slayerPattern by patternGroup.pattern(
+ "slayer",
+ "§7Slayer XP: §d.*§5/§d(?<xp>.*)"
+ )
+ private val dungeonPattern by patternGroup.pattern(
+ "dungeon",
+ "§7Dungeon Score: §d.*§5/§d(?<xp>.*)"
+ )
+
@SubscribeEvent
fun onInventoryOpen(event: InventoryFullyOpenedEvent) {
if (!SkyHanniMod.feature.dev.debug.copyRngMeter) return
val map = mutableMapOf<NEUInternalName, Long>()
- val slayerPattern = "§7Slayer XP: §d.*§5/§d(?<xp>.*)".toPattern()
- val dungeonPattern = "§7Dungeon Score: §d.*§5/§d(?<xp>.*)".toPattern()
for (item in event.inventoryItems.values) {
for (line in item.getLore()) {
slayerPattern.matchMatcher(line) {
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
index e44cccd9a..6b52d1eb2 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
@@ -26,11 +26,6 @@ import kotlin.time.Duration.Companion.seconds
object ItemUtils {
- // TODO USE SH-REPO
- private val patternInFront = "(?: *§8(\\+§\\w)?(?<amount>[\\d.km,]+)(x )?)?(?<name>.*)".toPattern()
- private val patternBehind = "(?<name>(?:['\\w-]+ ?)+)(?:§8x(?<amount>[\\d,]+))?".toPattern()
- private val petLevelPattern = "\\[Lvl (.*)] (.*)".toPattern()
-
private val ignoredPetStrings = listOf(
"Archer",
"Berserk",
@@ -66,7 +61,7 @@ object ItemUtils {
fun isRecombobulated(stack: ItemStack) = stack.isRecombobulated()
- fun isPet(name: String): Boolean = petLevelPattern.matches(name) && !ignoredPetStrings.any { name.contains(it) }
+ fun isPet(name: String): Boolean = UtilsPatterns.petLevelPattern.matches(name) && !ignoredPetStrings.any { name.contains(it) }
fun maxPetLevel(name: String) = if (name.contains("Golden Dragon")) 200 else 100
@@ -323,18 +318,17 @@ object ItemUtils {
return itemAmountCache[input]!!
}
- var matcher = patternInFront.matcher(input)
- if (matcher.matches()) {
- val itemName = matcher.group("name")
+ UtilsPatterns.readAmountBeforePattern.matchMatcher(input) {
+ val itemName = group("name")
if (!itemName.contains("§8x")) {
- return makePair(input, itemName.trim(), matcher)
+ return makePair(input, itemName.trim(), this)
}
}
var string = input.trim()
val color = string.substring(0, 2)
string = string.substring(2)
- matcher = patternBehind.matcher(string)
+ val matcher = UtilsPatterns.readAmountAfterPattern.matcher(string)
if (!matcher.matches()) {
println("")
println("input: '$input'")
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt
index 926efc877..001315baf 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt
@@ -4,31 +4,21 @@ import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.mixins.transformers.AccessorChatComponentText
import at.hannibal2.skyhanni.utils.GuiRenderUtils.darkenColor
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
-import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.GuiUtilRenderComponents
import net.minecraft.util.ChatComponentText
import net.minecraft.util.IChatComponent
import java.util.Base64
-import java.util.NavigableMap
import java.util.UUID
import java.util.function.Predicate
import java.util.regex.Matcher
import java.util.regex.Pattern
object StringUtils {
-
- // TODO USE SH-REPO
- private val playerChatPattern = "(?<important>.*?)(?:§[f7r])*: .*".toPattern()
- private val chatUsernamePattern =
- "^(?:§\\w\\[§\\w\\d+§\\w] )?(?:(?:§\\w)+\\S )?(?<rankedName>(?:§\\w\\[\\w.+] )?(?:§\\w)?(?<username>\\w+))(?: (?:§\\w)?\\[.+?])?".toPattern()
private val whiteSpaceResetPattern = "^(?:\\s|§r)*|(?:\\s|§r)*$".toPattern()
private val whiteSpacePattern = "^\\s*|\\s*$".toPattern()
private val resetPattern = "(?i)§R".toPattern()
- private val isRomanPattern by RepoPattern.pattern(
- "utils.string.isroman",
- "^M{0,3}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})"
- )
+ private val stringColourPattern = "§[0123456789abcdef].*".toPattern()
fun String.trimWhiteSpaceAndResets(): String = whiteSpaceResetPattern.matcher(this).replaceAll("")
fun String.trimWhiteSpace(): String = whiteSpacePattern.matcher(this).replaceAll("")
@@ -68,31 +58,17 @@ object StringUtils {
return builder.toString()
}
- /**
- * From https://stackoverflow.com/questions/10711494/get-values-in-treemap-whose-string-keys-start-with-a-pattern
- */
- fun <T> subMapWithKeysThatAreSuffixes(prefix: String, map: NavigableMap<String?, T>): Map<String?, T>? {
- if ("" == prefix) return map
- val lastKey = nextLexicographicallyStringWithSameLength(prefix)
- return map.subMap(prefix, true, lastKey, false)
- }
-
- fun nextLexicographicallyStringWithSameLength(input: String): String {
- val lastCharPosition = input.length - 1
- val inputWithoutLastChar = input.substring(0, lastCharPosition)
- val lastChar = input[lastCharPosition]
- val incrementedLastChar = (lastChar.code + 1).toChar()
- return inputWithoutLastChar + incrementedLastChar
- }
-
fun UUID.toDashlessUUID(): String {
return toString().replace("-", "")
}
- // TODO find better name for this method
+
inline fun <T> Pattern.matchMatcher(text: String, consumer: Matcher.() -> T) =
matcher(text).let { if (it.matches()) consumer(it) else null }
+ inline fun <T> Pattern.findMatcher(text: String, consumer: Matcher.() -> T) =
+ matcher(text).let { if (it.find()) consumer(it) else null }
+
private fun String.internalCleanPlayerName(): String {
val split = trim().split(" ")
return if (split.size > 1) {
@@ -122,9 +98,7 @@ object StringUtils {
}
fun getColor(string: String, default: Int, darker: Boolean = true): Int {
- val stringPattern = "§[0123456789abcdef].*".toPattern()
-
- val matcher = stringPattern.matcher(string)
+ val matcher = stringColourPattern.matcher(string)
if (matcher.matches()) {
val colorInt = Minecraft.getMinecraft().fontRendererObj.getColorCode(string[1])
return if (darker) {
@@ -265,7 +239,7 @@ object StringUtils {
private fun matchPlayerChatMessage(string: String): Matcher? {
var username = ""
- var matcher = playerChatPattern.matcher(string)
+ var matcher = UtilsPatterns.playerChatPattern.matcher(string)
if (matcher.matches()) {
username = matcher.group("important").removeResets()
}
@@ -282,7 +256,7 @@ object StringUtils {
username = username.removePrefix("§dFrom ")
username = username.removePrefix("§dTo ")
- matcher = chatUsernamePattern.matcher(username)
+ matcher = UtilsPatterns.chatUsernamePattern.matcher(username)
return if (matcher.matches()) matcher else null
}
@@ -298,6 +272,6 @@ object StringUtils {
fun String?.equalsIgnoreColor(string: String?) = this?.let { it.removeColor() == string?.removeColor() } ?: false
fun String.isRoman(): Boolean {
- return isRomanPattern.matches(this)
+ return UtilsPatterns.isRomanPattern.matches(this)
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt
index 43af202a8..4ca07e423 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt
@@ -14,9 +14,6 @@ import kotlin.time.toDuration
object TimeUtils {
- private val pattern =
- "(?:(?<y>\\d+) ?y(?:\\w* ?)?)?(?:(?<d>\\d+) ?d(?:\\w* ?)?)?(?:(?<h>\\d+) ?h(?:\\w* ?)?)?(?:(?<m>\\d+) ?m(?:\\w* ?)?)?(?:(?<s>\\d+) ?s(?:\\w* ?)?)?".toPattern()
-
fun Duration.format(
biggestUnit: TimeUnit = TimeUnit.YEAR,
showMilliSeconds: Boolean = false,
@@ -86,7 +83,7 @@ object TimeUtils {
fun getDuration(string: String) = getMillis_(string.replace("m", "m ").replace(" ", " ").trim())
- private fun getMillis_(string: String) = pattern.matchMatcher(string.lowercase().trim()) {
+ private fun getMillis_(string: String) = UtilsPatterns.timeAmountPattern.matchMatcher(string.lowercase().trim()) {
val years = group("y")?.toLong() ?: 0L
val days = group("d")?.toLong() ?: 0L
val hours = group("h")?.toLong() ?: 0L
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt b/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt
index 8f4d78239..5f466f33f 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt
@@ -45,6 +45,32 @@ object UtilsPatterns {
"item.petlevel",
"(?:§f§f)?§7\\[Lvl (?<level>\\d+)] .*"
)
+ val readAmountBeforePattern by patternGroup.pattern(
+ "item.amount.front",
+ "(?: *§8(\\+§\\w)?(?<amount>[\\d.km,]+)(x )?)?(?<name>.*)"
+ )
+ val readAmountAfterPattern by patternGroup.pattern(
+ "item.amount.behind",
+ "(?<name>(?:['\\w-]+ ?)+)(?:§8x(?<amount>[\\d,]+))?"
+ )
+
+ val timeAmountPattern by patternGroup.pattern(
+ "time.amount",
+ "(?:(?<y>\\d+) ?y(?:\\w* ?)?)?(?:(?<d>\\d+) ?d(?:\\w* ?)?)?(?:(?<h>\\d+) ?h(?:\\w* ?)?)?(?:(?<m>\\d+) ?m(?:\\w* ?)?)?(?:(?<s>\\d+) ?s(?:\\w* ?)?)?"
+ )
+
+ val playerChatPattern by patternGroup.pattern(
+ "string.playerchat",
+ "(?<important>.*?)(?:§[f7r])*: .*"
+ )
+ val chatUsernamePattern by patternGroup.pattern(
+ "string.chatusername",
+ "^(?:§\\w\\[§\\w\\d+§\\w] )?(?:(?:§\\w)+\\S )?(?<rankedName>(?:§\\w\\[\\w.+] )?(?:§\\w)?(?<username>\\w+))(?: (?:§\\w)?\\[.+?])?"
+ )
+ val isRomanPattern by RepoPattern.pattern(
+ "string.isroman",
+ "^M{0,3}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})"
+ )
val sackPattern by patternGroup.pattern(
"item.sack",