aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/data/PartyAPI.kt
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-06-04 12:40:50 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-06-04 12:40:50 +0200
commit27ca631ac727377f0514954dd179ef145a8feba4 (patch)
treeab5ba44d4cd5f47d995df6f81a67846e200c2753 /src/main/java/at/hannibal2/skyhanni/data/PartyAPI.kt
parent1a6dc6ad26494c6769159a9b404ccfb837065bcf (diff)
downloadskyhanni-27ca631ac727377f0514954dd179ef145a8feba4.tar.gz
skyhanni-27ca631ac727377f0514954dd179ef145a8feba4.tar.bz2
skyhanni-27ca631ac727377f0514954dd179ef145a8feba4.zip
Added Command Autocomplete
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data/PartyAPI.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/PartyAPI.kt67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/PartyAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/PartyAPI.kt
new file mode 100644
index 000000000..21f76998c
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/data/PartyAPI.kt
@@ -0,0 +1,67 @@
+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)
+ println("partyMembers: $partyMembers")
+ }
+ "(?<name>.*) §r§ejoined the party.".toPattern().matchMatcher(message) {
+ val name = group("name").cleanPlayerName()
+ partyMembers.add(name)
+ println("partyMembers: $partyMembers")
+ }
+ "§eYou'll be partying with: §r(?<names>.*)".toPattern().matchMatcher(message) {
+ for (name in group("names").split(", ")) {
+ partyMembers.add(name.cleanPlayerName())
+ }
+ println("partyMembers: $partyMembers")
+ }
+
+ // one member got removed
+ "(?<name>.*) §r§ehas left the party.".toPattern().matchMatcher(message) {
+ val name = group("name").cleanPlayerName()
+ partyMembers.remove(name)
+ println("partyMembers: $partyMembers")
+ }
+ "(?<name>.*) §r§ehas been removed from the party.".toPattern().matchMatcher(message) {
+ val name = group("name").cleanPlayerName()
+ partyMembers.remove(name)
+ println("partyMembers: $partyMembers")
+ }
+ "(?<name>.*) neuberddo§r§e because they were offline.".toPattern().matchMatcher(message) {
+ val name = group("name").cleanPlayerName()
+ partyMembers.remove(name)
+ println("partyMembers: $partyMembers")
+ }
+
+ // party disbanded
+ ".* §r§ehas disbanded the party!".toPattern().matchMatcher(message) {
+ partyMembers.clear()
+ println("partyMembers: $partyMembers")
+ }
+ "§eYou have been kicked from the party by §r.* §r§e".toPattern().matchMatcher(message) {
+ partyMembers.clear()
+ println("partyMembers: $partyMembers")
+ }
+ if (message == "§eYou left the party." ||
+ message == "§cThe party was disbanded because all invites expired and the party was empty."
+ ) {
+ partyMembers.clear()
+ println("partyMembers: $partyMembers")
+ }
+ }
+}