Don't let someone join a party they are already in

This commit is contained in:
Teriuihi 2022-03-02 17:30:19 +01:00
parent 23e7c57333
commit 7c9b12c394
2 changed files with 6 additions and 0 deletions

View File

@ -271,6 +271,7 @@ public final class Config {
public static String REMOVED_USER_FROM_PARTY = "<green>You removed <player> from the chat party!</green>";
public static String NOT_A_PARTY_MEMBER = "<red><player> is not a member of your party!</red>";
public static String ALREADY_IN_PARTY = "<red>You're already in a party!</red>";
public static String ALREADY_IN_THIS_PARTY = "<red>You're already in <party>!</red>";
public static String SENT_PARTY_INV = "<green>You send a chat party invite to <player>!</green>";
public static String JOIN_PARTY_CLICK_MESSAGE = "<click:run_command:'/party join <party> <party_password>'>" +
"<dark_aqua>You received an invite to join <party>, click this message to accept.</dark_aqua></click>";

View File

@ -10,6 +10,7 @@ import com.alttd.velocitychat.VelocityChat;
import com.alttd.velocitychat.commands.SubCommand;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.proxy.Player;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import java.util.ArrayList;
@ -45,6 +46,10 @@ public class Join implements SubCommand {
// party.addUser(ChatUserManager.getChatUser(player.getUniqueId())); //Removed until we can get nicknames to translate to colors correctly
ChatUser chatUser = ChatUserManager.getChatUser(player.getUniqueId());
if (chatUser.getPartyId() == party.getPartyId()) {
source.sendMessage(Utility.parseMiniMessage(Config.ALREADY_IN_THIS_PARTY, Placeholder.miniMessage("party", party.getPartyName())));
return;
}
party.addUser(chatUser, player.getUsername());
source.sendMessage(Utility.parseMiniMessage(Config.JOINED_PARTY, Placeholder.miniMessage("party_name", party.getPartyName())));
VelocityChat.getPlugin().getChatHandler().sendPartyMessage(party,