diff --git a/Towny/src/main/java/com/palmergames/bukkit/towny/command/HelpMenu.java b/Towny/src/main/java/com/palmergames/bukkit/towny/command/HelpMenu.java index 5466f56d68..bb930d66b2 100644 --- a/Towny/src/main/java/com/palmergames/bukkit/towny/command/HelpMenu.java +++ b/Towny/src/main/java/com/palmergames/bukkit/towny/command/HelpMenu.java @@ -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")); diff --git a/Towny/src/main/java/com/palmergames/bukkit/towny/command/TownCommand.java b/Towny/src/main/java/com/palmergames/bukkit/towny/command/TownCommand.java index 36c02c1d66..9ca2440ad9 100644 --- a/Towny/src/main/java/com/palmergames/bukkit/towny/command/TownCommand.java +++ b/Towny/src/main/java/com/palmergames/bukkit/towny/command/TownCommand.java @@ -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 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()); diff --git a/Towny/src/main/resources/ChangeLog.txt b/Towny/src/main/resources/ChangeLog.txt index 65fc7777bb..28ef2d304f 100644 --- a/Towny/src/main/resources/ChangeLog.txt +++ b/Towny/src/main/resources/ChangeLog.txt @@ -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. \ No newline at end of file + - 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.) \ No newline at end of file diff --git a/Towny/src/main/resources/lang/en-US.yml b/Towny/src/main/resources/lang/en-US.yml index 15d5aa4f28..7743355894 100644 --- a/Towny/src/main/resources/lang/en-US.yml +++ b/Towny/src/main/resources/lang/en-US.yml @@ -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" \ No newline at end of file +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." \ No newline at end of file