aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/chat
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/chat
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/chat')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/chat/ArachneChatMessageHider.kt22
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/chat/PlayerDeathMessages.kt7
2 files changed, 22 insertions, 7 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/ArachneChatMessageHider.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/ArachneChatMessageHider.kt
index 54dc6bed0..57a9a5f9e 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/chat/ArachneChatMessageHider.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/chat/ArachneChatMessageHider.kt
@@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.events.LorenzChatEvent
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 ArachneChatMessageHider {
@@ -12,9 +13,19 @@ class ArachneChatMessageHider {
private val config get() = SkyHanniMod.feature.chat
private var hideArachneDeadMessage = false
- // TODO USE SH-REPO
- private val arachneCallingPattern = "§4☄ §r.* §r§eplaced an §r§9Arachne's Calling§r§e!.*".toPattern()
- private val arachneCrystalPattern = "§4☄ §r.* §r§eplaced an Arachne Crystal! Something is awakening!".toPattern()
+ private val patternGroup = RepoPattern.group("chat.arachne")
+ private val arachneCallingPattern by patternGroup.pattern(
+ "calling",
+ "§4☄ §r.* §r§eplaced an §r§9Arachne's Calling§r§e!.*"
+ )
+ private val arachneCrystalPattern by patternGroup.pattern(
+ "crystal",
+ "§4☄ §r.* §r§eplaced an Arachne Crystal! Something is awakening!"
+ )
+ private val arachneSpawnPattern by patternGroup.pattern(
+ "spawn",
+ "§c\\[BOSS] Arachne§r§f: (?:The Era of Spiders begins now\\.|Ahhhh\\.\\.\\.A Calling\\.\\.\\.)"
+ )
@SubscribeEvent
fun onChat(event: LorenzChatEvent) {
@@ -36,8 +47,9 @@ class ArachneChatMessageHider {
return true
}
- if (message == "§c[BOSS] Arachne§r§f: Ahhhh...A Calling...") return true
- if (message == "§c[BOSS] Arachne§r§f: The Era of Spiders begins now.") return true
+ arachneSpawnPattern.matchMatcher(message) {
+ return true
+ }
if (message == "§a§l▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬") {
hideArachneDeadMessage = !hideArachneDeadMessage
diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerDeathMessages.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerDeathMessages.kt
index 3f0c4b700..5516cbe77 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerDeathMessages.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerDeathMessages.kt
@@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.getLorenzVec
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.client.entity.EntityOtherPlayerMP
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -18,9 +19,11 @@ class PlayerDeathMessages {
private val lastTimePlayerSeen = mutableMapOf<String, Long>()
- // TODO USE SH-REPO
//§c ☠ §r§7§r§bZeroHazel§r§7 was killed by §r§8§lAshfang§r§7§r§7.
- private val deathMessagePattern = "§c ☠ §r§7§r§.(?<name>.+)§r§7 (?<reason>.+)".toPattern()
+ private val deathMessagePattern by RepoPattern.pattern(
+ "chat.player.death",
+ "§c ☠ §r§7§r§.(?<name>.+)§r§7 (?<reason>.+)"
+ )
@SubscribeEvent
fun onTick(event: LorenzTickEvent) {