From 4f27f560cf650acce62e727c8a813173b0e00f8d Mon Sep 17 00:00:00 2001 From: calmwolfs Date: Mon, 1 Jan 2024 18:01:39 -0500 Subject: [PATCH] migrate PartyAPI --- .../at/hannibal2/skyhanni/data/PartyAPI.kt | 64 +++++++++++++++---- 1 file changed, 50 insertions(+), 14 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/PartyAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/PartyAPI.kt index 90fe4783ebc3..1fb3718b3498 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/PartyAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/PartyAPI.kt @@ -8,24 +8,60 @@ 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 at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.random.Random object PartyAPI { - // TODO USE SH-REPO - private val youJoinedPartyPattern = "§eYou have joined (?.*)'s §eparty!".toPattern() - private val othersJoinedPartyPattern = "(?.*) §ejoined the party.".toPattern() - private val othersInThePartyPattern = "§eYou'll be partying with: (?.*)".toPattern() - private val otherLeftPattern = "(?.*) §ehas left the party.".toPattern() - private val otherKickedPattern = "(?.*) §ehas been removed from the party.".toPattern() - private val otherOfflineKickedPattern = "§eKicked (?.*) because they were offline.".toPattern() - private val otherDisconnectedPattern = - "(?.*) §ewas removed from your party because they disconnected.".toPattern() - private val transferPattern = "The party was transferred to .* because (?.*) left".toPattern() - private val disbandedPattern = ".* §ehas disbanded the party!".toPattern() - private val kickedPattern = "§eYou have been kicked from the party by .* §e".toPattern() - private val partyMembersStartPattern = "§6Party Members \\(\\d+\\)".toPattern() - private val partyMemberListPattern = "Party (?:Leader|Moderators|Members): (?.*)".toPattern() + private val youJoinedPartyPattern by RepoPattern.pattern( + "data.party.you.joined", + "§eYou have joined (?.*)'s §eparty!" + ) + private val othersJoinedPartyPattern by RepoPattern.pattern( + "data.party.others.joined", + "(?.*) §ejoined the party\\." + ) + private val othersInThePartyPattern by RepoPattern.pattern( + "data.party.others.inparty", + "§eYou'll be partying with: (?.*)" + ) + private val otherLeftPattern by RepoPattern.pattern( + "data.party.others.left", + "(?.*) §ehas left the party\\." + ) + private val otherKickedPattern by RepoPattern.pattern( + "data.party.others.kicked", + "(?.*) §ehas been removed from the party\\." + ) + private val otherOfflineKickedPattern by RepoPattern.pattern( + "data.party.others.offline", + "§eKicked (?.*) because they were offline\\." + ) + private val otherDisconnectedPattern by RepoPattern.pattern( + "data.party.others.disconnect", + "(?.*) §ewas removed from your party because they disconnected\\." + ) + private val transferPattern by RepoPattern.pattern( + "data.party.others.transfer", + "The party was transferred to .* because (?.*) left" + ) + private val disbandedPattern by RepoPattern.pattern( + "data.party.others.disband", + ".* §ehas disbanded the party!" + ) + private val kickedPattern by RepoPattern.pattern( + "data.party.you.kicked", + "§eYou have been kicked from the party by .* §e" + ) + private val partyMembersStartPattern by RepoPattern.pattern( + "data.party.members.start", + "§6Party Members \\(\\d+\\)" + ) + + private val partyMemberListPattern by RepoPattern.pattern( + "data.party.members.list", + "Party (?:Leader|Moderators|Members): (?.*)" + ) val partyMembers = mutableListOf()