aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/event/diana/InquisitorSharingConfig.java5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt12
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt6
3 files changed, 17 insertions, 6 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/event/diana/InquisitorSharingConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/event/diana/InquisitorSharingConfig.java
index c719a7101..567d9c3cb 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/event/diana/InquisitorSharingConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/event/diana/InquisitorSharingConfig.java
@@ -34,4 +34,9 @@ public class InquisitorSharingConfig {
@ConfigOption(name = "Show Despawn Time", desc = "Show the time until the shared Inquisitor will despawn.")
@ConfigEditorBoolean
public boolean showDespawnTime = true;
+
+ @Expose
+ @ConfigOption(name = "Read Global Chat", desc = "Also read the global chat for detecting inquistiors, not only party chat.")
+ @ConfigEditorBoolean
+ public boolean globalChat = false;
}
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 31de087cd..42a4c8850 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
@@ -13,6 +13,7 @@ import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.KeyboardManager
import at.hannibal2.skyhanni.utils.LorenzLogger
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils.hasGroup
import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.SoundUtils
@@ -34,12 +35,13 @@ 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 partyOnlyCoordsPattern by patternGroup.pattern(
"party.onlycoords",
- "§9Party §8> (?<playerName>.+)§f: §rx: (?<x>[^ ]+),? y: (?<y>[^ ]+),? z: (?<z>[^ ]+)"
+ "(?<party>§9Party §8> )?(?<playerName>.+)§f: §rx: (?<x>[^ ]+),? y: (?<y>[^ ]+),? z: (?<z>[^ ]+)"
)
//Support for https://www.chattriggers.com/modules/v/inquisitorchecker
@@ -48,11 +50,11 @@ object InquisitorWaypointShare {
*/
private val partyInquisitorCheckerPattern by patternGroup.pattern(
"party.inquisitorchecker",
- "§9Party §8> (?<playerName>.+)§f: §rA MINOS INQUISITOR has spawned near \\[(?<area>.*)] at Coords (?<x>[^ ]+) (?<y>[^ ]+) (?<z>[^ ]+)"
+ "(?<party>§9Party §8> )?(?<playerName>.+)§f: §rA MINOS INQUISITOR has spawned near \\[(?<area>.*)] at Coords (?<x>[^ ]+) (?<y>[^ ]+) (?<z>[^ ]+)"
)
private val diedPattern by patternGroup.pattern(
"died",
- "§9Party §8> (?<playerName>.*)§f: §rInquisitor dead!"
+ "(?<party>§9Party §8> )?(?<playerName>.*)§f: §rInquisitor dead!"
)
private var time = 0L
@@ -258,6 +260,7 @@ object InquisitorWaypointShare {
}
}
diedPattern.matchMatcher(message) {
+ if (block()) return
val rawName = group("playerName")
val name = rawName.cleanPlayerName()
val displayName = rawName.cleanPlayerName(displayName = true)
@@ -267,7 +270,10 @@ object InquisitorWaypointShare {
}
}
+ private fun Matcher.block(): Boolean = !hasGroup("party") && !config.globalChat
+
private fun Matcher.detectFromChat(): Boolean {
+ if (block()) return false
val rawName = group("playerName")
val x = group("x").trim().toDoubleOrNull() ?: return false
val y = group("y").trim().toDoubleOrNull() ?: return false
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
index c45bcae0e..df622503a 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
@@ -356,9 +356,9 @@ object LorenzUtils {
* Get the group, otherwise, return null
* @param groupName The group name in the pattern
*/
- fun Matcher.groupOrNull(groupName: String): String? {
- return runCatching { this.group(groupName) }.getOrNull()
- }
+ fun Matcher.groupOrNull(groupName: String): String? = runCatching { this.group(groupName) }.getOrNull()
+
+ fun Matcher.hasGroup(groupName: String): Boolean = groupOrNull(groupName) != null
fun inAdvancedMiningIsland() =
IslandType.DWARVEN_MINES.isInIsland() || IslandType.CRYSTAL_HOLLOWS.isInIsland() || IslandType.MINESHAFT.isInIsland()