diff options
author | Appability <appable@icloud.com> | 2023-08-03 19:35:43 -0700 |
---|---|---|
committer | Appability <appable@icloud.com> | 2023-08-03 19:40:02 -0700 |
commit | 73e33fc7ae762f56144336fe8d07782db62b8b36 (patch) | |
tree | 9c584cea74e94e5307c55b62d7c19e7b9ea34f1f /src | |
parent | e93af75b3df15f41b9a1701763c6815e774eae55 (diff) | |
download | skyhanni-73e33fc7ae762f56144336fe8d07782db62b8b36.tar.gz skyhanni-73e33fc7ae762f56144336fe8d07782db62b8b36.tar.bz2 skyhanni-73e33fc7ae762f56144336fe8d07782db62b8b36.zip |
watchdog hider (version two)
Diffstat (limited to 'src')
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 7e314e16d..e7725a410 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" + } +} + + |