From aaca5f08d47732b3db5329a3a9404281b21d2f55 Mon Sep 17 00:00:00 2001 From: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Date: Sat, 8 Jun 2024 12:18:03 +1000 Subject: Backend: Add annotation to smaller modules (#2022) --- .../skyhanni/features/chat/WatchdogHider.kt | 23 ++++++++++------------ .../features/chat/playerchat/PlayerChatFilter.kt | 23 +++++++++++----------- 2 files changed, 21 insertions(+), 25 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/features/chat') diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/WatchdogHider.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/WatchdogHider.kt index 11e51e686..6e1b00504 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/WatchdogHider.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/WatchdogHider.kt @@ -4,33 +4,39 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.data.ChatManager import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraft.util.IChatComponent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class WatchdogHider { +@SkyHanniModule +object WatchdogHider { private var inWatchdog = false private var blockedLines = 0 private var startLineComponent: IChatComponent? = null + private const val START_LINE = "§f" + private const val ANNOUNCEMENT_LINE = "§4[WATCHDOG ANNOUNCEMENT]" + private const val END_LINE = "§c" + @SubscribeEvent fun onChat(event: LorenzChatEvent) { if (!LorenzUtils.onHypixel || !SkyHanniMod.feature.chat.filterType.watchDog) return when (event.message) { - watchdogStartLine -> { + START_LINE -> { startLineComponent = event.chatComponent blockedLines = 0 } - watchdogAnnouncementLine -> { + ANNOUNCEMENT_LINE -> { ChatManager.retractMessage(startLineComponent, "watchdog") startLineComponent = null inWatchdog = true } - watchdogEndLine -> { + END_LINE -> { event.blockedReason = "watchdog" inWatchdog = false } @@ -46,17 +52,8 @@ class WatchdogHider { } } - companion object { - - private const val watchdogStartLine = "§f" - private const val watchdogAnnouncementLine = "§4[WATCHDOG ANNOUNCEMENT]" - private const val watchdogEndLine = "§c" - } - @SubscribeEvent fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { event.move(3, "chat.watchDog", "chat.filterType.watchDog") } } - - diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatFilter.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatFilter.kt index cb6f68c4d..23de5de6b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatFilter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatFilter.kt @@ -2,26 +2,25 @@ package at.hannibal2.skyhanni.features.chat.playerchat import at.hannibal2.skyhanni.data.jsonobjects.repo.PlayerChatFilterJson import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.MultiFilter import net.minecraft.util.IChatComponent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class PlayerChatFilter { +@SkyHanniModule +object PlayerChatFilter { - companion object { + private val filters = mutableMapOf() - private val filters = mutableMapOf() - - fun shouldChatFilter(original: IChatComponent): Boolean { - val message = original.formattedText.lowercase() - for (filter in filters) { - filter.value.matchResult(message)?.let { - return true - } + fun shouldChatFilter(original: IChatComponent): Boolean { + val message = original.formattedText.lowercase() + for (filter in filters) { + filter.value.matchResult(message)?.let { + return true } - - return false } + + return false } @SubscribeEvent -- cgit