diff options
author | Jordan <77755681+Jordyrat@users.noreply.github.com> | 2024-08-31 21:50:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-31 22:50:16 +0200 |
commit | 755a36d801e29a3c517e9c7abbf4ef6b016b026a (patch) | |
tree | 4840b326a24f8a0d9d957c0c0713930103548bba /src/main/java/at/hannibal2/skyhanni/data/PartyAPI.kt | |
parent | 79d891d5a3e1bffd31491a921757ccf7ab66b5fe (diff) | |
download | skyhanni-755a36d801e29a3c517e9c7abbf4ef6b016b026a.tar.gz skyhanni-755a36d801e29a3c517e9c7abbf4ef6b016b026a.tar.bz2 skyhanni-755a36d801e29a3c517e9c7abbf4ef6b016b026a.zip |
Feature: Reverse Party Transfer (#1712)
Co-authored-by: BuildTools <unconfigured@null.spigotmc.org>
Co-authored-by: Cal <cwolfson58@gmail.com>
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data/PartyAPI.kt')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/PartyAPI.kt | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/PartyAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/PartyAPI.kt index f06619169..2ee30c27e 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/PartyAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/PartyAPI.kt @@ -21,68 +21,69 @@ object PartyAPI { private val patternGroup = RepoPattern.group("data.party") private val youJoinedPartyPattern by patternGroup.pattern( "you.joined", - "§eYou have joined (?<name>.*)'s? §eparty!" + "§eYou have joined (?<name>.*)'s? §eparty!", ) private val othersJoinedPartyPattern by patternGroup.pattern( "others.joined", - "(?<name>.*) §ejoined the party\\." + "(?<name>.*) §ejoined the party\\.", ) private val othersInThePartyPattern by patternGroup.pattern( "others.inparty", - "§eYou'll be partying with: (?<names>.*)" + "§eYou'll be partying with: (?<names>.*)", ) private val otherLeftPattern by patternGroup.pattern( "others.left", - "(?<name>.*) §ehas left the party\\." + "(?<name>.*) §ehas left the party\\.", ) private val otherKickedPattern by patternGroup.pattern( "others.kicked", - "(?<name>.*) §ehas been removed from the party\\." + "(?<name>.*) §ehas been removed from the party\\.", ) private val otherOfflineKickedPattern by patternGroup.pattern( "others.offline", - "§eKicked (?<name>.*) because they were offline\\." + "§eKicked (?<name>.*) because they were offline\\.", ) private val otherDisconnectedPattern by patternGroup.pattern( "others.disconnect", - "(?<name>.*) §ewas removed from your party because they disconnected\\." + "(?<name>.*) §ewas removed from your party because they disconnected\\.", ) private val transferOnLeavePattern by patternGroup.pattern( "others.transfer.leave", - "The party was transferred to (?<newowner>.*) because (?<name>.*) left" + "The party was transferred to (?<newowner>.*) because (?<name>.*) left", ) - private val transferVoluntaryPattern by patternGroup.pattern( + val transferVoluntaryPattern by patternGroup.pattern( "others.transfer.voluntary", - "The party was transferred to (?<newowner>.*) by .*" + "The party was transferred to (?<newowner>.*) by (?<name>.*)", ) private val disbandedPattern by patternGroup.pattern( "others.disband", - ".* §ehas disbanded the party!" + ".* §ehas disbanded the party!", ) private val kickedPattern by patternGroup.pattern( "you.kicked", - "§eYou have been kicked from the party by .* §e" + "§eYou have been kicked from the party by .* §e", ) private val partyMembersStartPattern by patternGroup.pattern( "members.start", - "§6Party Members \\(\\d+\\)" + "§6Party Members \\(\\d+\\)", ) private val partyMemberListPattern by patternGroup.pattern( "members.list.withkind", - "Party (?<kind>Leader|Moderators|Members): (?<names>.*)" + "Party (?<kind>Leader|Moderators|Members): (?<names>.*)", ) private val kuudraFinderJoinPattern by patternGroup.pattern( "kuudrafinder.join", - "§dParty Finder §f> (?<name>.*?) §ejoined the group! \\(§[a-fA-F0-9]+Combat Level \\d+§e\\)" + "§dParty Finder §f> (?<name>.*?) §ejoined the group! \\(§[a-fA-F0-9]+Combat Level \\d+§e\\)", ) private val dungeonFinderJoinPattern by patternGroup.pattern( "dungeonfinder.join", - "§dParty Finder §f> (?<name>.*?) §ejoined the dungeon group! \\(§[a-fA-F0-9].* Level \\d+§[a-fA-F0-9]\\)" + "§dParty Finder §f> (?<name>.*?) §ejoined the dungeon group! \\(§[a-fA-F0-9].* Level \\d+§[a-fA-F0-9]\\)", ) val partyMembers = mutableListOf<String>() var partyLeader: String? = null + var prevPartyLeader: String? = null fun listMembers() { val size = partyMembers.size @@ -145,15 +146,15 @@ object PartyAPI { // one member got removed otherLeftPattern.matchMatcher(message) { val name = group("name").cleanPlayerName() - partyMembers.remove(name) + removeWithLeader(name) } otherKickedPattern.matchMatcher(message) { val name = group("name").cleanPlayerName() - partyMembers.remove(name) + removeWithLeader(name) } otherOfflineKickedPattern.matchMatcher(message) { val name = group("name").cleanPlayerName() - partyMembers.remove(name) + removeWithLeader(name) } otherDisconnectedPattern.matchMatcher(message) { val name = group("name").cleanPlayerName() @@ -166,6 +167,7 @@ object PartyAPI { } transferVoluntaryPattern.matchMatcher(message.removeColor()) { partyLeader = group("newowner").cleanPlayerName() + prevPartyLeader = group("name").cleanPlayerName() } // party disbanded @@ -201,6 +203,13 @@ object PartyAPI { } } + private fun removeWithLeader(name: String) { + partyMembers.remove(name) + if (name == prevPartyLeader) { + prevPartyLeader = null + } + } + private fun addPlayer(playerName: String) { if (partyMembers.contains(playerName)) return if (playerName == LorenzUtils.getPlayerName()) return @@ -210,5 +219,6 @@ object PartyAPI { private fun partyLeft() { partyMembers.clear() partyLeader = null + prevPartyLeader = null } } |