blob: c5eefc603803d62f1a342d9c09edcc30dfd0dd8c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
package at.hannibal2.skyhanni.features.chat
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.utils.LorenzUtils
import net.minecraft.util.IChatComponent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class WatchdogHider {
private var inWatchdog = false
private var blockedLines = 0
private var startLineComponent: IChatComponent? = null
@SubscribeEvent
fun onChatMessage(event: LorenzChatEvent) {
if (!LorenzUtils.onHypixel || !SkyHanniMod.feature.chat.filterType.watchDog) return
when (event.message) {
watchdogStartLine -> {
startLineComponent = event.chatComponent
blockedLines = 0
}
watchdogAnnouncementLine -> {
ChatManager.retractMessage(startLineComponent, "watchdog")
startLineComponent = null
inWatchdog = true
}
watchdogEndLine -> {
event.blockedReason = "watchdog"
inWatchdog = false
}
}
if (inWatchdog) {
event.blockedReason = "watchdog"
blockedLines++
if (blockedLines > 10) {
blockedLines = 0
inWatchdog = false
}
}
}
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")
}
}
|