From 89b1065be05abe5fd725cb4f74064e99c8f67440 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Sat, 30 Sep 2023 10:14:11 -0700 Subject: [PATCH] don't allow inviting players already in party --- .../carbon/common/command/commands/PartyCommands.java | 5 +++++ .../net/draycia/carbon/common/messages/CarbonMessages.java | 3 +++ common/src/main/resources/locale/messages-en_US.properties | 1 + 3 files changed, 9 insertions(+) diff --git a/common/src/main/java/net/draycia/carbon/common/command/commands/PartyCommands.java b/common/src/main/java/net/draycia/carbon/common/command/commands/PartyCommands.java index 61b7a89ff..cc9de8a09 100644 --- a/common/src/main/java/net/draycia/carbon/common/command/commands/PartyCommands.java +++ b/common/src/main/java/net/draycia/carbon/common/command/commands/PartyCommands.java @@ -172,6 +172,11 @@ private void invitePlayer(final CommandContext ctx) { this.messages.mustBeInParty(player); return; } + final @Nullable Party recipientParty = recipient.party().join(); + if (recipientParty != null && recipientParty.id().equals(party.id())) { + this.messages.alreadyInParty(player, recipient.displayName()); + return; + } this.partyInvites.sendInvite(player.uuid(), recipient.uuid(), party.id()); this.messages.receivedPartyInvite(recipient, player.displayName(), party.name()); } diff --git a/common/src/main/java/net/draycia/carbon/common/messages/CarbonMessages.java b/common/src/main/java/net/draycia/carbon/common/messages/CarbonMessages.java index 4ed324ca5..92793fdf3 100644 --- a/common/src/main/java/net/draycia/carbon/common/messages/CarbonMessages.java +++ b/common/src/main/java/net/draycia/carbon/common/messages/CarbonMessages.java @@ -469,6 +469,9 @@ void errorCommandCommandExecution( @Message("command.party.cannot_invite_self") void cannotInviteSelf(Audience audience); + @Message("command.party.already_in_party") + void alreadyInParty(Audience audience, Component displayName); + @Message("command.party.description") Component partyDesc(); diff --git a/common/src/main/resources/locale/messages-en_US.properties b/common/src/main/resources/locale/messages-en_US.properties index 05a96a940..4165423e3 100644 --- a/common/src/main/resources/locale/messages-en_US.properties +++ b/common/src/main/resources/locale/messages-en_US.properties @@ -80,6 +80,7 @@ command.party.create.description=Create a new party. command.party.invite.description=Invite a player to your party. command.party.accept.description=Accept party invites. command.party.leave.description=Leave your current party. +command.party.already_in_party= is already in your party. command.party.disband.description=Disband your current party. config.reload.failed=Config failed to reload config.reload.success=Config reloaded successfully