summaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/misc
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/misc')
-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
14 files changed, 161 insertions, 76 deletions
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 {