From a3d1910c7dee5a47d42ad21f5210547d52722ede Mon Sep 17 00:00:00 2001 From: Teriuihi Date: Tue, 15 Feb 2022 02:32:38 +0100 Subject: [PATCH] Fixed party notifs and spy --- api/src/main/java/com/alttd/chat/config/Config.java | 4 +++- .../velocitychat/commands/partysubcommands/Join.java | 10 +++++++++- .../velocitychat/commands/partysubcommands/Name.java | 9 ++++++++- .../com/alttd/velocitychat/handlers/ChatHandler.java | 1 + 4 files changed, 21 insertions(+), 3 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 7c92832..4bb1ae0 100755 --- a/api/src/main/java/com/alttd/chat/config/Config.java +++ b/api/src/main/java/com/alttd/chat/config/Config.java @@ -247,7 +247,7 @@ public final class Config { } public static String PARTY_FORMAT = "(\"> → ) "; - public static String PARTY_SPY = "PC: : "; + public static String PARTY_SPY = "PC: : "; public static String NO_PERMISSION = "You don't have permission to use this command."; public static String NO_CONSOLE = "This command can not be used by console"; public static String CREATED_PARTY = "You created a chat party called: " + @@ -260,6 +260,7 @@ public final class Config { public static String NOT_ONLINE = " must be online to receive an invite."; public static String INVALID_PASSWORD = "Invalid password."; public static String JOINED_PARTY = "You joined !"; + public static String PLAYER_JOINED_PARTY = " joined !"; public static String NOTIFY_FINDING_NEW_OWNER = "Since you own this chat party a new party owner will be chosen."; public static String LEFT_PARTY = "You have left the chat party!"; public static String OWNER_LEFT_PARTY = "[ChatParty]: left the chat party, the new party owner is "; @@ -298,6 +299,7 @@ public final class Config { NOT_ONLINE = getString("party.messages.not-online", NOT_ONLINE); INVALID_PASSWORD = getString("party.messages.invalid-password", INVALID_PASSWORD); JOINED_PARTY = getString("party.messages.joined-party", JOINED_PARTY); + PLAYER_JOINED_PARTY = getString("party.messages.player-joined-party", PLAYER_JOINED_PARTY); NOTIFY_FINDING_NEW_OWNER = getString("party.messages.notify-finding-new-owner", NOTIFY_FINDING_NEW_OWNER); LEFT_PARTY = getString("party.messages.left-party", LEFT_PARTY); OWNER_LEFT_PARTY = getString("party.messages.owner-left-party", OWNER_LEFT_PARTY); diff --git a/velocity/src/main/java/com/alttd/velocitychat/commands/partysubcommands/Join.java b/velocity/src/main/java/com/alttd/velocitychat/commands/partysubcommands/Join.java index 4b346ed..e17198f 100644 --- a/velocity/src/main/java/com/alttd/velocitychat/commands/partysubcommands/Join.java +++ b/velocity/src/main/java/com/alttd/velocitychat/commands/partysubcommands/Join.java @@ -3,8 +3,10 @@ package com.alttd.velocitychat.commands.partysubcommands; import com.alttd.chat.config.Config; import com.alttd.chat.managers.ChatUserManager; import com.alttd.chat.managers.PartyManager; +import com.alttd.chat.objects.ChatUser; import com.alttd.chat.objects.Party; import com.alttd.chat.util.Utility; +import com.alttd.velocitychat.VelocityChat; import com.alttd.velocitychat.commands.SubCommand; import com.velocitypowered.api.command.CommandSource; import com.velocitypowered.api.proxy.Player; @@ -42,8 +44,14 @@ public class Join implements SubCommand { } // party.addUser(ChatUserManager.getChatUser(player.getUniqueId())); //Removed until we can get nicknames to translate to colors correctly - party.addUser(ChatUserManager.getChatUser(player.getUniqueId()), player.getUsername()); + ChatUser chatUser = ChatUserManager.getChatUser(player.getUniqueId()); + party.addUser(chatUser, player.getUsername()); source.sendMessage(Utility.parseMiniMessage(Config.JOINED_PARTY, Placeholder.miniMessage("party_name", party.getPartyName()))); + VelocityChat.getPlugin().getChatHandler().sendPartyMessage(party, + Utility.parseMiniMessage(Config.PLAYER_JOINED_PARTY, + Placeholder.component("player_name", chatUser.getDisplayName()), + Placeholder.miniMessage("party_name", party.getPartyName()) + ), null); } @Override diff --git a/velocity/src/main/java/com/alttd/velocitychat/commands/partysubcommands/Name.java b/velocity/src/main/java/com/alttd/velocitychat/commands/partysubcommands/Name.java index 8261aff..d9a685c 100644 --- a/velocity/src/main/java/com/alttd/velocitychat/commands/partysubcommands/Name.java +++ b/velocity/src/main/java/com/alttd/velocitychat/commands/partysubcommands/Name.java @@ -1,6 +1,7 @@ package com.alttd.velocitychat.commands.partysubcommands; import com.alttd.chat.config.Config; +import com.alttd.chat.managers.ChatUserManager; import com.alttd.chat.managers.PartyManager; import com.alttd.chat.objects.Party; import com.alttd.chat.util.Utility; @@ -48,8 +49,14 @@ public class Name implements SubCommand { )); return; } + + String oldName = party.getPartyName(); party.setPartyName(args[1]); - VelocityChat.getPlugin().getChatHandler().sendPartyMessage(party, Utility.parseMiniMessage(Config.RENAMED_PARTY), null); + VelocityChat.getPlugin().getChatHandler().sendPartyMessage(party, Utility.parseMiniMessage(Config.RENAMED_PARTY, + Placeholder.component("owner", ChatUserManager.getChatUser(player.getUniqueId()).getDisplayName()), + Placeholder.miniMessage("old_name", oldName), + Placeholder.miniMessage("new_name", args[1]) + ), null); } @Override diff --git a/velocity/src/main/java/com/alttd/velocitychat/handlers/ChatHandler.java b/velocity/src/main/java/com/alttd/velocitychat/handlers/ChatHandler.java index c09ec37..74c9034 100755 --- a/velocity/src/main/java/com/alttd/velocitychat/handlers/ChatHandler.java +++ b/velocity/src/main/java/com/alttd/velocitychat/handlers/ChatHandler.java @@ -131,6 +131,7 @@ public class ChatHandler { Map> placeholders = new HashMap<>(); placeholders.put("sender", Replacement.component(senderName)); + placeholders.put("username", Replacement.miniMessage(player.getUsername())); placeholders.put("party", Replacement.miniMessage(party.getPartyName())); placeholders.put("message", Replacement.miniMessage(updatedMessage)); placeholders.put("server", Replacement.miniMessage(serverConnection.getServer().getServerInfo().getName()));