blob: 5a4fb4f99fc425110906cab413f547627f9b3ec8 (
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
|
package at.hannibal2.skyhanni.data
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.utils.StringUtils.cleanPlayerName
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
object GuildAPI {
private var inGuildMessage = false
private val list = mutableListOf<String>()
@SubscribeEvent
fun onChat(event: LorenzChatEvent) {
val message = event.message
if (message.startsWith("§6Guild Name: ")) {
inGuildMessage = true
list.clear()
return
}
if (message.startsWith("§eTotal Members: ")) {
inGuildMessage = false
ProfileStorageData.playerSpecific?.guildMembers?.let {
it.clear()
it.addAll(list)
}
list.clear()
return
}
if (inGuildMessage) {
if (message.contains("●")) {
for (word in message.split("●")) {
list.add(word.cleanPlayerName())
}
}
}
}
fun isInGuild(name: String) = ProfileStorageData.playerSpecific?.guildMembers?.let {
name in it
} ?: false
}
|