Skip to content

Commit

Permalink
- Add /t invite sent removeall command.
Browse files Browse the repository at this point in the history
    - Closes #7238.
  - New Command: /town invite sent removeall
    - Removes all of the invites which a town has sent.
    - Requires the towny.command.town.invite.add permission node to use
(same node used for removing one by one.)
LlmDl committed Feb 7, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 6ba9920 commit 9dcee47
Showing 4 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -678,6 +678,7 @@ protected MenuBuilder load() {
.add("[player]", Translatable.of("town_invite_help_1"))
.add("-[player]", Translatable.of("town_invite_help_2"))
.add("sent", Translatable.of("town_invite_help_3"))
.add("sent removeall", Translatable.of("town_invite_help_7"))
.add("received", Translatable.of("town_invite_help_4"))
.add("accept [nation]", Translatable.of("town_invite_help_5"))
.add("deny [nation]", Translatable.of("town_invite_help_6"));
Original file line number Diff line number Diff line change
@@ -799,6 +799,17 @@ private void parseInviteCommand(Player player, String[] args) throws TownyExcept
}

private void parseTownInviteSentCommand(Player player, String[] args, Resident resident, String sent) throws TownyException {
if (args.length == 0) {
listTownSentInvites(player, args, resident, sent);
return;
}
switch (args[0].toLowerCase(Locale.ROOT)) {
case "removeall" -> removeAllTownSentInvites(resident, player);
default -> HelpMenu.TOWN_INVITE.send(player);
}
}

private void listTownSentInvites(Player player, String[] args, Resident resident, String sent) throws TownyException {
checkPermOrThrow(player, PermissionNodes.TOWNY_COMMAND_TOWN_INVITE_LIST_SENT.getNode());

List<Invite> sentinvites = resident.getTown().getSentInvites();
@@ -807,6 +818,12 @@ private void parseTownInviteSentCommand(Player player, String[] args, Resident r
TownyMessaging.sendMessage(player, sent);
}

private void removeAllTownSentInvites(Resident resident, Player player) throws TownyException {
checkPermOrThrow(player, PermissionNodes.TOWNY_COMMAND_TOWN_INVITE_ADD.getNode());
resident.getTown().getSentInvites().forEach(i -> i.decline(true));
TownyMessaging.sendMessage(player, Translatable.of("msg_all_of_your_towns_sent_invites_have_been_cancelled"));
}

private void parseTownInviteReceivedCommand(Player player, String[] args, Resident resident, String received) throws TownyException {
checkPermOrThrow(player, PermissionNodes.TOWNY_COMMAND_TOWN_INVITE_LIST_RECEIVED.getNode());

7 changes: 6 additions & 1 deletion Towny/src/main/resources/ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -9504,4 +9504,9 @@ v0.92.0.11:
- Remove explicit citizens dependency, courtesy of Warrior with PR #7236.
- Replace deprecated plugin loader with manager, courtesy of Warrior with PR #7237.
- Fix potential NPE when two towns are merged with no nation.
- Closes #7240.
- Closes #7240.
- Add /t invite sent removeall command.
- Closes #7238.
- New Command: /town invite sent removeall
- Removes all of the invites which a town has sent.
- Requires the towny.command.town.invite.add permission node to use (same node used for removing one by one.)
5 changes: 4 additions & 1 deletion Towny/src/main/resources/lang/en-US.yml
Original file line number Diff line number Diff line change
@@ -885,6 +885,7 @@ town_invite_help_3: 'Lists all of your sent invites'
town_invite_help_4: 'Lists all of the invites you''ve received'
town_invite_help_5: 'Accept a request to join a nation'
town_invite_help_6: 'Deny a request to join a nation'
town_invite_help_7: 'Remove all of the invites your town has sent out'
nation_invite_help_1: 'Invite a town to your nation'
nation_invite_help_2: 'Revoke an invite, that was sent to a town'
nation_invite_help_3: 'List all of the invites sent to towns'
@@ -2428,4 +2429,6 @@ msg_err_you_cannot_outlaw_your_mayor: "You cannot outlaw your town's mayor."

msg_err_you_cannot_outlaw_because_of_rank: "You cannot outlaw %s because of a town rank they hold."

status_nation_sanctioned_towns: "Sanctioned Towns"
status_nation_sanctioned_towns: "Sanctioned Towns"

msg_all_of_your_towns_sent_invites_have_been_cancelled: "All of your town's sent invites have been cancelled."

0 comments on commit 9dcee47

Please sign in to comment.