aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2023-08-05 17:38:48 +0200
committerGitHub <noreply@github.com>2023-08-05 17:38:48 +0200
commit18856a631c55bbd25725c07a90b0bc2108f5e61f (patch)
treebffad3ad2c09f4adedd989c05f565a098eb03d4d /src/main/java
parent697d2788967ef2c86328c288799f73a8396ba566 (diff)
parent73e33fc7ae762f56144336fe8d07782db62b8b36 (diff)
downloadskyhanni-18856a631c55bbd25725c07a90b0bc2108f5e61f.tar.gz
skyhanni-18856a631c55bbd25725c07a90b0bc2108f5e61f.tar.bz2
skyhanni-18856a631c55bbd25725c07a90b0bc2108f5e61f.zip
Merge pull request #360
Watchdog hider improvement (version 2)
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt7
-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
3 files changed, 52 insertions, 14 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index 91d0e6f46..cc0711452 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -13,10 +13,7 @@ import at.hannibal2.skyhanni.features.bazaar.BazaarBestSellMethod
import at.hannibal2.skyhanni.features.bazaar.BazaarCancelledBuyOrderClipboard
import at.hannibal2.skyhanni.features.bazaar.BazaarOrderHelper
import at.hannibal2.skyhanni.features.bingo.*
-import at.hannibal2.skyhanni.features.chat.ArachneChatMessageHider
-import at.hannibal2.skyhanni.features.chat.ChatFilter
-import at.hannibal2.skyhanni.features.chat.CompactBestiaryChatMessage
-import at.hannibal2.skyhanni.features.chat.PlayerDeathMessages
+import at.hannibal2.skyhanni.features.chat.*
import at.hannibal2.skyhanni.features.chat.playerchat.PlayerChatFilter
import at.hannibal2.skyhanni.features.chat.playerchat.PlayerChatModifier
import at.hannibal2.skyhanni.features.commands.PartyTransferCommand
@@ -375,7 +372,7 @@ class SkyHanniMod {
loadModule(HarpKeybinds())
loadModule(EnderNodeTracker())
loadModule(CompactBestiaryChatMessage())
-
+ loadModule(WatchdogHider())
init()
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"
+ }
+}
+
+