From f91973d60948d449cc45a4add901e6fe43aebd62 Mon Sep 17 00:00:00 2001 From: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Date: Fri, 16 Feb 2024 21:21:43 +1100 Subject: Moved many regex patterns in the repo and code cleanup. #871 --- .../features/chat/ArachneChatMessageHider.kt | 22 +++++++++++++++++----- .../skyhanni/features/chat/PlayerDeathMessages.kt | 7 +++++-- 2 files changed, 22 insertions(+), 7 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/features/chat') 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() - // 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§.(?.+)§r§7 (?.+)".toPattern() + private val deathMessagePattern by RepoPattern.pattern( + "chat.player.death", + "§c ☠ §r§7§r§.(?.+)§r§7 (?.+)" + ) @SubscribeEvent fun onTick(event: LorenzTickEvent) { -- cgit