blob: 12648724732e555b8e511e11c83e1eaefc833c29 (
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
|
package at.hannibal2.skyhanni.data
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.utils.StringUtils.cleanPlayerName
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class PartyAPI {
companion object {
val partyMembers = mutableListOf<String>()
}
@SubscribeEvent
fun onChat(event: LorenzChatEvent) {
val message = event.message
// new member joined
"§eYou have joined §r(?<name>.*)'s §r§eparty!".toPattern().matchMatcher(message) {
val name = group("name").cleanPlayerName()
partyMembers.add(name)
}
"(?<name>.*) §r§ejoined the party.".toPattern().matchMatcher(message) {
val name = group("name").cleanPlayerName()
partyMembers.add(name)
}
"§eYou'll be partying with: §r(?<names>.*)".toPattern().matchMatcher(message) {
for (name in group("names").split(", ")) {
partyMembers.add(name.cleanPlayerName())
}
}
// one member got removed
"(?<name>.*) §r§ehas left the party.".toPattern().matchMatcher(message) {
val name = group("name").cleanPlayerName()
partyMembers.remove(name)
}
"(?<name>.*) §r§ehas been removed from the party.".toPattern().matchMatcher(message) {
val name = group("name").cleanPlayerName()
partyMembers.remove(name)
}
"(?<name>.*) neuberddo§r§e because they were offline.".toPattern().matchMatcher(message) {
val name = group("name").cleanPlayerName()
partyMembers.remove(name)
}
// party disbanded
".* §r§ehas disbanded the party!".toPattern().matchMatcher(message) {
partyMembers.clear()
}
"§eYou have been kicked from the party by §r.* §r§e".toPattern().matchMatcher(message) {
partyMembers.clear()
}
if (message == "§eYou left the party." ||
message == "§cThe party was disbanded because all invites expired and the party was empty."
) {
partyMembers.clear()
}
}
}
|