aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2024-04-06 01:05:08 +0200
committerGitHub <noreply@github.com>2024-04-06 01:05:08 +0200
commitaff767bb841f5e2d502c8ac0cf69e9a3c0d5781f (patch)
tree795ab47524298adb9eb1c46aff206ead5b86924f /src/main/java/at/hannibal2
parentf4ef154fbb1a5abd51b96158bf6ccc575a1543ef (diff)
downloadskyhanni-aff767bb841f5e2d502c8ac0cf69e9a3c0d5781f.tar.gz
skyhanni-aff767bb841f5e2d502c8ac0cf69e9a3c0d5781f.tar.bz2
skyhanni-aff767bb841f5e2d502c8ac0cf69e9a3c0d5781f.zip
Improvement: Added support for ct inquisitorchecker (v2) (#1359)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt68
1 files changed, 46 insertions, 22 deletions
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 b4f6050dd..31de087cd 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
@@ -26,6 +26,7 @@ import net.minecraft.network.play.server.S02PacketChat
import net.minecraftforge.event.entity.EntityJoinWorldEvent
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import java.util.regex.Matcher
import kotlin.time.Duration.Companion.seconds
object InquisitorWaypointShare {
@@ -33,9 +34,21 @@ object InquisitorWaypointShare {
private val config get() = SkyHanniMod.feature.event.diana.inquisitorSharing
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"
+ /**
+ * REGEX-TEST: §9Party §8> User Name§f: §rx: 2.3, y: 4.5, z: 6.7
+ */
+ private val partyOnlyCoordsPattern by patternGroup.pattern(
+ "party.onlycoords",
+ "§9Party §8> (?<playerName>.+)§f: §rx: (?<x>[^ ]+),? y: (?<y>[^ ]+),? z: (?<z>[^ ]+)"
+ )
+
+ //Support for https://www.chattriggers.com/modules/v/inquisitorchecker
+ /**
+ * REGEX-TEST: §9Party §8> UserName§f: §rA MINOS INQUISITOR has spawned near [Foraging Island ] at Coords 1 2 3
+ */
+ private val partyInquisitorCheckerPattern by patternGroup.pattern(
+ "party.inquisitorchecker",
+ "§9Party §8> (?<playerName>.+)§f: §rA MINOS INQUISITOR has spawned near \\[(?<area>.*)] at Coords (?<x>[^ ]+) (?<y>[^ ]+) (?<z>[^ ]+)"
)
private val diedPattern by patternGroup.pattern(
"died",
@@ -233,27 +246,16 @@ object InquisitorWaypointShare {
val message = LorenzUtils.stripVanillaMessage(messageComponent.formattedText)
if (packet.type.toInt() != 0) return
- partyPattern.matchMatcher(message) {
- val rawName = group("playerName")
- val x = group("x").trim().toInt()
- val y = group("y").trim().toInt()
- val z = group("z").trim().toInt()
- val location = LorenzVec(x, y, z)
-
- val name = rawName.cleanPlayerName()
- val displayName = rawName.cleanPlayerName(displayName = true)
- if (!waypoints.containsKey(name)) {
- ChatUtils.chat("$displayName §l§efound an inquisitor at §l§c$x $y $z!")
- if (name != LorenzUtils.getPlayerName()) {
- LorenzUtils.sendTitle("§dINQUISITOR §efrom §b$displayName", 5.seconds)
- SoundUtils.playBeepSound()
- }
+ partyInquisitorCheckerPattern.matchMatcher(message) {
+ if (detectFromChat()) {
+ event.isCanceled = true
}
- val inquis = SharedInquisitor(name, displayName, location, SimpleTimeMark.now())
- waypoints = waypoints.editCopy { this[name] = inquis }
- GriffinBurrowHelper.update()
+ }
- event.isCanceled = true
+ partyOnlyCoordsPattern.matchMatcher(message) {
+ if (detectFromChat()) {
+ event.isCanceled = true
+ }
}
diedPattern.matchMatcher(message) {
val rawName = group("playerName")
@@ -265,6 +267,28 @@ object InquisitorWaypointShare {
}
}
+ private fun Matcher.detectFromChat(): Boolean {
+ val rawName = group("playerName")
+ val x = group("x").trim().toDoubleOrNull() ?: return false
+ val y = group("y").trim().toDoubleOrNull() ?: return false
+ val z = group("z").trim().toDoubleOrNull() ?: return false
+ val location = LorenzVec(x, y, z)
+
+ val name = rawName.cleanPlayerName()
+ val displayName = rawName.cleanPlayerName(displayName = true)
+ if (!waypoints.containsKey(name)) {
+ ChatUtils.chat("$displayName §l§efound an inquisitor at §l§c${x.toInt()} ${y.toInt()} ${z.toInt()}!")
+ if (name != LorenzUtils.getPlayerName()) {
+ LorenzUtils.sendTitle("§dINQUISITOR §efrom §b$displayName", 5.seconds)
+ SoundUtils.playBeepSound()
+ }
+ }
+ val inquis = SharedInquisitor(name, displayName, location, SimpleTimeMark.now())
+ waypoints = waypoints.editCopy { this[name] = inquis }
+ GriffinBurrowHelper.update()
+ return true
+ }
+
private fun isEnabled() = DianaAPI.isDoingDiana() && config.enabled
fun maybeRemove(inquis: SharedInquisitor) {