Skip to content

Commit

Permalink
don't allow inviting yourself to party
Browse files Browse the repository at this point in the history
  • Loading branch information
jpenilla committed Sep 30, 2023
1 parent 24dcb81 commit 416be97
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ private void createParty(final CommandContext<Commander> ctx) {
private void invitePlayer(final CommandContext<Commander> ctx) {
final CarbonPlayer player = ((PlayerCommander) ctx.getSender()).carbonPlayer();
final CarbonPlayer recipient = ctx.get("player");
if (recipient.uuid().equals(player.uuid())) {
this.messages.cannotInviteSelf(player);
return;
}
final @Nullable Party party = player.party().join();
if (party == null) {
this.messages.mustBeInParty(player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,9 @@ void errorCommandCommandExecution(
@Message("command.party.must_be_in_party")
void mustBeInParty(Audience audience);

@Message("command.party.cannot_invite_self")
void cannotInviteSelf(Audience audience);

@Message("command.party.description")
Component partyDesc();

Expand Down
1 change: 1 addition & 0 deletions common/src/main/resources/locale/messages-en_US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ command.party.left_party=<green>Successfully left party '</green><party_name><gr
command.party.disbanded=<green>Successfully disbanded party '</green><party_name><green>'.
command.party.cannot_disband_multiple_members=<red>Cannot disband party '</red><party_name><red>', you are not the last member.
command.party.must_be_in_party=<red>You must be in a party to use this command.
command.party.cannot_invite_self=<red>You cannot invite yourself.
command.party.description=Get info about your current party.
command.party.create.description=Create a new party.
command.party.invite.description=Invite a player to your party.
Expand Down

0 comments on commit 416be97

Please sign in to comment.