From cfdefef783d29851e94b31544c97cec2713d2f8d Mon Sep 17 00:00:00 2001 From: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Date: Tue, 2 Apr 2024 10:16:21 +1100 Subject: Revert "Improvement: Added support for ct inquisitorchecker (#1315)" (#1337) This reverts commit 526f1a3e5eb364d240894847f50fcab006688d4d. --- .../event/diana/InquisitorWaypointShare.kt | 64 +++++++--------------- 1 file changed, 20 insertions(+), 44 deletions(-) (limited to 'src/main/java/at/hannibal2') 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 86ccb243c..b4f6050dd 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,7 +26,6 @@ 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 { @@ -34,21 +33,9 @@ object InquisitorWaypointShare { private val config get() = SkyHanniMod.feature.event.diana.inquisitorSharing private val patternGroup = RepoPattern.group("diana.waypoints") - /** - * REGEX-TEST: §9Party §8> User Name§f: §rx: 2.3, y: 4.5, z: 6.7 - */ private val partyPattern by patternGroup.pattern( "party", - "§9Party §8> (?.+)§f: §rx: (?[^ ]+),? y: (?[^ ]+),? 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 inquisitorCheckerPattern by patternGroup.pattern( - "party.inquisitorchecker", - "§9Party §8> (?.+)§f: §rA MINOS INQUISITOR has spawned near \\[(?.*)] at Coords (?[^ ]+) (?[^ ]+) (?[^ ]+)" + "§9Party §8> (?.*)§f: §rx: (?-?[0-9]{1,4}), y: (?-?[0-9]{1,4}), z: (?-?[0-9]{1,4})\\b" ) private val diedPattern by patternGroup.pattern( "died", @@ -246,16 +233,27 @@ object InquisitorWaypointShare { val message = LorenzUtils.stripVanillaMessage(messageComponent.formattedText) if (packet.type.toInt() != 0) return - inquisitorCheckerPattern.matchMatcher(message) { - if (detectFromChat()) { - event.isCanceled = true - } - } - partyPattern.matchMatcher(message) { - if (detectFromChat()) { - event.isCanceled = true + 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() + } } + val inquis = SharedInquisitor(name, displayName, location, SimpleTimeMark.now()) + waypoints = waypoints.editCopy { this[name] = inquis } + GriffinBurrowHelper.update() + + event.isCanceled = true } diedPattern.matchMatcher(message) { val rawName = group("playerName") @@ -267,28 +265,6 @@ 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) { -- cgit