-
-
Notifications
You must be signed in to change notification settings - Fork 193
/
ArachneChatMessageHider.kt
67 lines (56 loc) · 2.37 KB
/
ArachneChatMessageHider.kt
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
62
63
64
65
66
67
package at.hannibal2.skyhanni.features.chat
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@SkyHanniModule
object ArachneChatMessageHider {
private val config get() = SkyHanniMod.feature.chat
private var hideArachneDeadMessage = false
private val patternGroup = RepoPattern.group("chat.arachne")
val arachneCallingPattern by patternGroup.pattern(
"calling",
"§4☄ §r.* §r§eplaced an §r§9Arachne's Calling§r§e!.*"
)
val arachneCrystalPattern by patternGroup.pattern(
"crystal",
"§4☄ §r.* §r§eplaced an Arachne Crystal! Something is awakening!"
)
private val arachneSpawnPattern by patternGroup.pattern(
"spawn",
"§c\\[BOSS] Arachne§r§f: (?:The Era of Spiders begins now\\.|Ahhhh\\.\\.\\.A Calling\\.\\.\\.)"
)
@SubscribeEvent
fun onChat(event: LorenzChatEvent) {
if (!isEnabled()) return
if (LorenzUtils.skyBlockArea == "Arachne's Sanctuary") return
if (shouldHide(event.message)) {
event.blockedReason = "arachne"
}
}
private fun shouldHide(message: String): Boolean {
arachneCallingPattern.matchMatcher(message) {
return true
}
arachneCrystalPattern.matchMatcher(message) {
return true
}
arachneSpawnPattern.matchMatcher(message) {
return true
}
if (message == "§a§l▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬") {
hideArachneDeadMessage = !hideArachneDeadMessage
return true
}
if (message == " §r§6§lARACHNE DOWN!") {
hideArachneDeadMessage = true
}
return hideArachneDeadMessage
}
fun isEnabled() = IslandType.SPIDER_DEN.isInIsland() && config.hideArachneMessages
}