summaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/rift
diff options
context:
space:
mode:
authorCalMWolfs <94038482+CalMWolfs@users.noreply.github.com>2024-02-16 21:21:43 +1100
committerGitHub <noreply@github.com>2024-02-16 11:21:43 +0100
commitf91973d60948d449cc45a4add901e6fe43aebd62 (patch)
tree4c8c77ec4a9585a821651a034ebe5bed3308a6af /src/main/java/at/hannibal2/skyhanni/features/rift
parent26fe548fa9a5cfe29b130a0a5585278df3429ee9 (diff)
downloadskyhanni-f91973d60948d449cc45a4add901e6fe43aebd62.tar.gz
skyhanni-f91973d60948d449cc45a4add901e6fe43aebd62.tar.bz2
skyhanni-f91973d60948d449cc45a4add901e6fe43aebd62.zip
Moved many regex patterns in the repo and code cleanup. #871
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/rift')
-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
7 files changed, 65 insertions, 26 deletions
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")}.")
}