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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
package at.hannibal2.skyhanni.features.dungeon
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@SkyHanniModule
object DungeonBossMessages {
private val config get() = SkyHanniMod.feature.chat
private val bossPattern = "§([cd4])\\[BOSS] (.*)".toPattern()
private val excludedMessages = listOf(
"§c[BOSS] The Watcher§r§f: You have proven yourself. You may pass."
)
private val messageList = listOf(
// M7 – Dragons
"§cThe Crystal withers your soul as you hold it in your hands!",
"§cIt doesn't seem like that is supposed to go there."
)
private val messageContainsList = listOf(
" The Watcher§r§f: ",
" Bonzo§r§f: ",
" Scarf§r§f:",
"Professor§r§f",
" Livid§r§f: ",
" Enderman§r§f: ",
" Thorn§r§f: ",
" Sadan§r§f: ",
" Maxor§r§c: ",
" Storm§r§c: ",
" Goldor§r§c: ",
" Necron§r§c: ",
" §r§4§kWither King§r§c:"
)
private val messageEndsWithList = listOf(
" Necron§r§c: That is enough, fool!",
" Necron§r§c: Adventurers! Be careful of who you are messing with..",
" Necron§r§c: Before I have to deal with you myself."
)
@SubscribeEvent
fun onChat(event: LorenzChatEvent) {
if (!DungeonAPI.inDungeon()) return
if (!isBoss(event.message)) return
DungeonAPI.handleBossMessage(event.message)
if (config.dungeonBossMessages) {
event.blockedReason = "dungeon_boss"
}
}
/**
* Checks if the message is a boss message
* @return true if the message is a boss message
* @param message The message to check
* @see excludedMessages
* @see messageList
* @see messageContainsList
* @see messageEndsWithList
*/
private fun isBoss(message: String): Boolean {
// Cases that match below but should not be blocked
if (message in excludedMessages) return false
// Exact Matches
if (message in messageList) return true
// Matches Regex for Boss Prefix
bossPattern.matchMatcher(message) {
return messageContainsList.any { message.contains(it) } || messageEndsWithList.any { message.endsWith(it) }
}
return false
}
}
|