blob: b289d01100f2051759e08a780ad5b8dd44623bf3 (
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
package at.hannibal2.skyhanni.data
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.OSUtils
import at.hannibal2.skyhanni.utils.StringUtils.cleanPlayerName
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.StringUtils.removeResets
import at.hannibal2.skyhanni.utils.StringUtils.trimWhiteSpaceAndResets
import net.minecraft.client.Minecraft
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.random.Random
object PartyAPI {
val partyMembers = mutableListOf<String>()
fun listMembers() {
val size = partyMembers.size
if (size == 0) {
LorenzUtils.chat("§e[SkyHanni] No tracked party members!")
return
}
LorenzUtils.chat("§a[SkyHanni] Tracked party members §7($size) §f:")
for (member in partyMembers) {
LorenzUtils.chat(" §a- §7$member")
}
if (Random.nextDouble() < 0.1) {
OSUtils.openBrowser("https://www.youtube.com/watch?v=iANP7ib7CPA")
LorenzUtils.hoverableChat("§7Are You Ready To Party?", listOf("§b~Spongebob"))
}
}
@SubscribeEvent
fun onChat(event: LorenzChatEvent) {
// TODO USE SH-REPO
val message = event.message.trimWhiteSpaceAndResets().removeResets()
// new member joined
"§eYou have joined (?<name>.*)'s §eparty!".toPattern().matchMatcher(message) {
val name = group("name").cleanPlayerName()
if (!partyMembers.contains(name)) partyMembers.add(name)
}
"(?<name>.*) §ejoined the party.".toPattern().matchMatcher(message) {
val name = group("name").cleanPlayerName()
if (!partyMembers.contains(name)) partyMembers.add(name)
}
"§eYou'll be partying with: (?<names>.*)".toPattern().matchMatcher(message) {
for (name in group("names").split(", ")) {
val playerName = name.cleanPlayerName()
if (!partyMembers.contains(playerName)) partyMembers.add(playerName)
}
}
// one member got removed
"(?<name>.*) §ehas left the party.".toPattern().matchMatcher(message) {
val name = group("name").cleanPlayerName()
partyMembers.remove(name)
}
"(?<name>.*) §ehas been removed from the party.".toPattern().matchMatcher(message) {
val name = group("name").cleanPlayerName()
partyMembers.remove(name)
}
"§eKicked (?<name>.*) because they were offline.".toPattern().matchMatcher(message) {
val name = group("name").cleanPlayerName()
partyMembers.remove(name)
}
"(?<name>.*) §ewas removed from your party because they disconnected.".toPattern().matchMatcher(message) {
val name = group("name").cleanPlayerName()
partyMembers.remove(name)
}
"The party was transferred to .* because (?<name>.*) left".toPattern().matchMatcher(message.removeColor()) {
val name = group("name").cleanPlayerName()
partyMembers.remove(name)
}
// party disbanded
".* §ehas disbanded the party!".toPattern().matchMatcher(message) {
partyMembers.clear()
}
"§eYou have been kicked from the party by .* §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." ||
message == "§cYou are not currently in a party."
) {
partyMembers.clear()
}
// party list
"§6Party Members \\(\\d+\\)".toPattern().matchMatcher(message.removeResets()) {
partyMembers.clear()
}
"Party (?:Leader|Moderators|Members): (?<names>.*)".toPattern().matchMatcher(message.removeColor()) {
for (name in group("names").split(" ● ")) {
val playerName = name.replace(" ●", "").cleanPlayerName()
if (playerName == Minecraft.getMinecraft().thePlayer.name) continue
if (!partyMembers.contains(playerName)) partyMembers.add(playerName)
}
}
}
}
|