aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/chat
diff options
context:
space:
mode:
authorAppability <appable@icloud.com>2023-08-03 19:35:43 -0700
committerAppability <appable@icloud.com>2023-08-03 19:40:02 -0700
commit73e33fc7ae762f56144336fe8d07782db62b8b36 (patch)
tree9c584cea74e94e5307c55b62d7c19e7b9ea34f1f /src/main/java/at/hannibal2/skyhanni/features/chat
parente93af75b3df15f41b9a1701763c6815e774eae55 (diff)
downloadskyhanni-73e33fc7ae762f56144336fe8d07782db62b8b36.tar.gz
skyhanni-73e33fc7ae762f56144336fe8d07782db62b8b36.tar.bz2
skyhanni-73e33fc7ae762f56144336fe8d07782db62b8b36.zip
watchdog hider (version two)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/chat')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/chat/WatchdogHider.kt50
2 files changed, 50 insertions, 9 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt
index 84acf124e..a8733abff 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt
@@ -27,7 +27,6 @@ class ChatFilter {
isGuildExp(message) && config.guildExp -> "guild_exp"
friendJoin(message) && config.friendJoinLeft -> "friend_join"
killCombo(message) && config.killCombo -> "kill_combo"
- watchdogAnnouncement(message) && config.watchDog -> "watchdog"
profileJoin(message) && config.profileJoin -> "profile_join"
bazaarAndAHMiniMessages(message) && config.others -> "bz_ah_minis"
@@ -219,14 +218,6 @@ class ChatFilter {
return false
}
- private fun watchdogAnnouncement(message: String) = when {
- message == "§4[WATCHDOG ANNOUNCEMENT]" -> true
- message.matchRegex("§fWatchdog has banned §r§c§l(.*)§r§f players in the last 7 days.") -> true
- message.matchRegex("§fStaff have banned an additional §r§c§l(.*)§r§f in the last 7 days.") -> true
- message == "§cBlacklisted modifications are a bannable offense!" -> true
- else -> false
- }
-
private fun profileJoin(message: String) = when {
message.startsWith("§aYou are playing on profile: §e") -> true
message.startsWith("§8Profile ID: ") -> true
diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/WatchdogHider.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/WatchdogHider.kt
new file mode 100644
index 000000000..60ad41e61
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/chat/WatchdogHider.kt
@@ -0,0 +1,50 @@
+package at.hannibal2.skyhanni.features.chat
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.data.ChatManager
+import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils.makeAccessible
+import net.minecraft.client.Minecraft
+import net.minecraft.client.gui.ChatLine
+import net.minecraft.util.IChatComponent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.relauncher.ReflectionHelper
+
+class WatchdogHider {
+
+ private var inWatchdog = false
+ private var startLineComponent: IChatComponent? = null
+
+ @SubscribeEvent
+ fun onChatMessage(event: LorenzChatEvent) {
+ if (!LorenzUtils.onHypixel || !SkyHanniMod.feature.chat.watchDog) return
+
+ when (event.message) {
+ watchdogStartLine -> {
+ startLineComponent = event.chatComponent
+ }
+ watchdogAnnouncementLine -> {
+ ChatManager.retractMessage(startLineComponent, "watchdog")
+ startLineComponent = null
+ inWatchdog = true
+ }
+ watchdogEndLine -> {
+ event.blockedReason = "watchdog"
+ inWatchdog = false
+ }
+ }
+
+ if (inWatchdog) {
+ event.blockedReason = "watchdog"
+ }
+ }
+
+ companion object {
+ private const val watchdogStartLine = "§f"
+ private const val watchdogAnnouncementLine = "§4[WATCHDOG ANNOUNCEMENT]"
+ private const val watchdogEndLine = "§c"
+ }
+}
+
+