diff options
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/FriendAPI.kt | 3 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/IslandType.kt | 4 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/PartyAPI.kt | 43 |
3 files changed, 33 insertions, 17 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/FriendAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/FriendAPI.kt index 9585e2ab0..bca06d18c 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/FriendAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/FriendAPI.kt @@ -16,8 +16,9 @@ import java.io.FileReader import java.util.UUID class FriendAPI { - // TODO USE SH-REPO private val file = File("config/skyhanni/friends.json") + + // TODO USE SH-REPO private val removedFriendPattern = ".*\n§r§eYou removed §r(?<name>.*)§e from your friends list!§r§9§m\n.*".toPattern() private val addedFriendPattern = "§aYou are now friends with (?<name>.*)".toPattern() diff --git a/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt b/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt index 9d52e3df5..15195dec4 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt @@ -1,7 +1,7 @@ package at.hannibal2.skyhanni.data enum class IslandType(val displayName: String, val apiName: String = "null") { - // TODO USE SH-REPO + // TODO USE SH-REPO (for displayName only) PRIVATE_ISLAND("Private Island"), PRIVATE_ISLAND_GUEST("Private Island Guest"), THE_END("The End"), @@ -32,4 +32,4 @@ enum class IslandType(val displayName: String, val apiName: String = "null") { return entries.firstOrNull { it.displayName == name } ?: UNKNOWN } } -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/data/PartyAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/PartyAPI.kt index b289d0110..08344c51b 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/PartyAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/PartyAPI.kt @@ -13,6 +13,21 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.random.Random object PartyAPI { + // TODO USE SH-REPO + private val youJoinedPartyPattern = "§eYou have joined (?<name>.*)'s §eparty!".toPattern() + private val othersJoinedPartyPattern = "(?<name>.*) §ejoined the party.".toPattern() + private val othersInThePartyPattern = "§eYou'll be partying with: (?<names>.*)".toPattern() + private val otherLeftPattern = "(?<name>.*) §ehas left the party.".toPattern() + private val otherKickedPattern = "(?<name>.*) §ehas been removed from the party.".toPattern() + private val otherOfflineKickedPattern = "§eKicked (?<name>.*) because they were offline.".toPattern() + private val otherDisconnectedPattern = + "(?<name>.*) §ewas removed from your party because they disconnected.".toPattern() + private val transferPattern = "The party was transferred to .* because (?<name>.*) 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): (?<names>.*)".toPattern() + val partyMembers = mutableListOf<String>() fun listMembers() { @@ -34,19 +49,19 @@ object PartyAPI { @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) { + + youJoinedPartyPattern.matchMatcher(message) { val name = group("name").cleanPlayerName() if (!partyMembers.contains(name)) partyMembers.add(name) } - "(?<name>.*) §ejoined the party.".toPattern().matchMatcher(message) { + othersJoinedPartyPattern.matchMatcher(message) { val name = group("name").cleanPlayerName() if (!partyMembers.contains(name)) partyMembers.add(name) } - "§eYou'll be partying with: (?<names>.*)".toPattern().matchMatcher(message) { + othersInThePartyPattern.matchMatcher(message) { for (name in group("names").split(", ")) { val playerName = name.cleanPlayerName() if (!partyMembers.contains(playerName)) partyMembers.add(playerName) @@ -54,32 +69,32 @@ object PartyAPI { } // one member got removed - "(?<name>.*) §ehas left the party.".toPattern().matchMatcher(message) { + otherLeftPattern.matchMatcher(message) { val name = group("name").cleanPlayerName() partyMembers.remove(name) } - "(?<name>.*) §ehas been removed from the party.".toPattern().matchMatcher(message) { + otherKickedPattern.matchMatcher(message) { val name = group("name").cleanPlayerName() partyMembers.remove(name) } - "§eKicked (?<name>.*) because they were offline.".toPattern().matchMatcher(message) { + otherOfflineKickedPattern.matchMatcher(message) { val name = group("name").cleanPlayerName() partyMembers.remove(name) } - "(?<name>.*) §ewas removed from your party because they disconnected.".toPattern().matchMatcher(message) { + otherDisconnectedPattern.matchMatcher(message) { val name = group("name").cleanPlayerName() partyMembers.remove(name) } - "The party was transferred to .* because (?<name>.*) left".toPattern().matchMatcher(message.removeColor()) { + transferPattern.matchMatcher(message.removeColor()) { val name = group("name").cleanPlayerName() partyMembers.remove(name) } // party disbanded - ".* §ehas disbanded the party!".toPattern().matchMatcher(message) { + disbandedPattern.matchMatcher(message) { partyMembers.clear() } - "§eYou have been kicked from the party by .* §e".toPattern().matchMatcher(message) { + kickedPattern.matchMatcher(message) { partyMembers.clear() } if (message == "§eYou left the party." || @@ -90,11 +105,11 @@ object PartyAPI { } // party list - "§6Party Members \\(\\d+\\)".toPattern().matchMatcher(message.removeResets()) { + partyMembersStartPattern.matchMatcher(message.removeResets()) { partyMembers.clear() } - "Party (?:Leader|Moderators|Members): (?<names>.*)".toPattern().matchMatcher(message.removeColor()) { + partyMemberListPattern.matchMatcher(message.removeColor()) { for (name in group("names").split(" ● ")) { val playerName = name.replace(" ●", "").cleanPlayerName() if (playerName == Minecraft.getMinecraft().thePlayer.name) continue @@ -102,4 +117,4 @@ object PartyAPI { } } } -}
\ No newline at end of file +} |