From 8f6b8675b56503139b24dab1dbd8cdbcb2b26e46 Mon Sep 17 00:00:00 2001 From: Teriuihi Date: Sun, 30 Jan 2022 20:11:25 +0100 Subject: [PATCH] Notify players if their party member joins --- .../main/java/com/alttd/chat/config/Config.java | 2 ++ .../listeners/ProxyPlayerListener.java | 15 ++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/api/src/main/java/com/alttd/chat/config/Config.java b/api/src/main/java/com/alttd/chat/config/Config.java index b1aeef6..fabefcb 100755 --- a/api/src/main/java/com/alttd/chat/config/Config.java +++ b/api/src/main/java/com/alttd/chat/config/Config.java @@ -271,6 +271,7 @@ public final class Config { public static String SENT_PARTY_INV = "You send a chat party invite to !"; public static String JOIN_PARTY_CLICK_MESSAGE = " '>" + "You received an invite to join click this message to accept."; + public static String PARTY_MEMBER_ONLINE = "[ChatParty] joined Altitude!"; public static String PARTY_INFO = """ Chat party info: Name: @@ -298,6 +299,7 @@ public final class Config { NOT_A_PARTY_MEMBER = getString("party.messages.not-a-party-member", NOT_A_PARTY_MEMBER); JOIN_PARTY_CLICK_MESSAGE = getString("party.messages.join-party-click-message", JOIN_PARTY_CLICK_MESSAGE); SENT_PARTY_INV = getString("party.messages.sent-party-invite", SENT_PARTY_INV); + PARTY_MEMBER_ONLINE = getString("party.messages.party-member-online", PARTY_MEMBER_ONLINE); PARTY_INFO = getString("party.messages.party-info", PARTY_INFO); } diff --git a/velocity/src/main/java/com/alttd/velocitychat/listeners/ProxyPlayerListener.java b/velocity/src/main/java/com/alttd/velocitychat/listeners/ProxyPlayerListener.java index ac282b8..2ea6bdc 100755 --- a/velocity/src/main/java/com/alttd/velocitychat/listeners/ProxyPlayerListener.java +++ b/velocity/src/main/java/com/alttd/velocitychat/listeners/ProxyPlayerListener.java @@ -1,5 +1,7 @@ package com.alttd.velocitychat.listeners; +import com.alttd.chat.managers.ChatUserManager; +import com.alttd.chat.objects.ChatUser; import com.alttd.chat.util.Utility; import com.alttd.velocitychat.VelocityChat; import com.alttd.chat.config.Config; @@ -32,11 +34,14 @@ public class ProxyPlayerListener { UUID uuid = player.getUniqueId(); Party party = PartyManager.getParty(event.getPlayer().getUniqueId()); if (party == null) return; - ByteArrayDataOutput out = ByteStreams.newDataOutput(); - out.writeUTF("partylogin"); - out.writeUTF(String.valueOf(party.getPartyId())); - out.writeUTF(uuid.toString()); - VelocityChat.getPlugin().getProxy().getAllServers().forEach(registeredServer -> registeredServer.sendPluginMessage(VelocityChat.getPlugin().getChannelIdentifier(), out.toByteArray())); + ChatUser chatUser = ChatUserManager.getChatUser(uuid); + if (chatUser == null) + return; + VelocityChat.getPlugin().getChatHandler().sendPartyMessage(party, + Utility.parseMiniMessage(Config.PARTY_MEMBER_ONLINE, List.of( + Template.template("player", chatUser.getDisplayName()) + )), + chatUser.getIgnoredPlayers()); // TODO setup ChatUser on Proxy //VelocityChat.getPlugin().getChatHandler().addPlayer(new ChatPlayer(event.getPlayer().getUniqueId()));