aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/chat
diff options
context:
space:
mode:
authorCalMWolfs <94038482+CalMWolfs@users.noreply.github.com>2024-06-08 12:18:03 +1000
committerGitHub <noreply@github.com>2024-06-08 12:18:03 +1000
commitaaca5f08d47732b3db5329a3a9404281b21d2f55 (patch)
tree6e9888c91928ba5e49e1d736b28fe0f4c847faa8 /src/main/java/at/hannibal2/skyhanni/features/chat
parent0c53ce8afdd5f64d2764d5ce0d4f2f2a59a7b06e (diff)
downloadskyhanni-aaca5f08d47732b3db5329a3a9404281b21d2f55.tar.gz
skyhanni-aaca5f08d47732b3db5329a3a9404281b21d2f55.tar.bz2
skyhanni-aaca5f08d47732b3db5329a3a9404281b21d2f55.zip
Backend: Add annotation to smaller modules (#2022)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/chat')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/chat/WatchdogHider.kt23
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatFilter.kt23
2 files changed, 21 insertions, 25 deletions
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<String, MultiFilter>()
- private val filters = mutableMapOf<String, MultiFilter>()
-
- 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