From 0a3b53f9f1928b68092317cc4639e3900f64d687 Mon Sep 17 00:00:00 2001 From: Gamer153 Date: Fri, 22 Jul 2022 00:07:22 +0200 Subject: [PATCH 1/2] Add /ta town toggle upkeep --- resources/lang/en-US.yml | 10 ++++++++-- .../bukkit/towny/command/TownyAdminCommand.java | 7 ++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/resources/lang/en-US.yml b/resources/lang/en-US.yml index 2bfa0b4ce8..457ecc107e 100644 --- a/resources/lang/en-US.yml +++ b/resources/lang/en-US.yml @@ -1,5 +1,5 @@ name: Towny -version: 0.154 +version: 0.155 language: english author: ElgarL website: 'http://townyadvanced.github.io/' @@ -1751,4 +1751,10 @@ msg_purchased_blocks_unset: 'The town %s has had their purchased townblocks remo msg_purchased_blocks_changed: 'The town %s has been given %s bought townblocks, they currently have %s bought townblocks.' #Added in 0.154 -msg_comptype_upkeep: 'Upkeep' \ No newline at end of file +msg_comptype_upkeep: 'Upkeep' + +# Added in 0.155 +# Message shown when toggling town upkeep admin setting +msg_town_upkeep_setting_set_to: 'The town %s has had their upkeep setting set to %s.' +# Message shown when toggling nation upkeep admin setting +msg_nation_upkeep_setting_set_to: 'The nation %s has had their upkeep setting set to %s.' diff --git a/src/com/palmergames/bukkit/towny/command/TownyAdminCommand.java b/src/com/palmergames/bukkit/towny/command/TownyAdminCommand.java index 033cf8fff9..4c802af422 100644 --- a/src/com/palmergames/bukkit/towny/command/TownyAdminCommand.java +++ b/src/com/palmergames/bukkit/towny/command/TownyAdminCommand.java @@ -152,7 +152,7 @@ public class TownyAdminCommand extends BaseCommand implements CommandExecutor { "forcemerge" ); private static final List adminTownToggleTabCompletes = Stream.concat(TownCommand.townToggleTabCompletes.stream(), - Arrays.asList("forcepvp", "unlimitedclaims").stream()).collect(Collectors.toList()); + Arrays.asList("forcepvp", "unlimitedclaims", "upkeep").stream()).collect(Collectors.toList()); private static final List adminNationTabCompletes = Arrays.asList( "add", @@ -1333,6 +1333,11 @@ public void parseAdminTownCommand(String[] split) throws TownyException { town.setHasUnlimitedClaims(choice.orElse(!town.hasUnlimitedClaims())); town.save(); TownyMessaging.sendMsg(sender, Translatable.of("msg_town_unlimitedclaims_setting_set_to", town.getName(), town.hasUnlimitedClaims())); + } else if (split[2].equalsIgnoreCase("upkeep")) { + + town.setHasUpkeep(!town.hasUpkeep()); + town.save(); + TownyMessaging.sendMsg(sender, Translatable.of("msg_town_upkeep_setting_set_to", town.getName(), town.hasUpkeep())); } else TownCommand.townToggle(sender, StringMgmt.remArgs(split, 2), true, town); From 18679293d7059b267f7f53c22bd1415935d369fb Mon Sep 17 00:00:00 2001 From: Gamer153 Date: Fri, 22 Jul 2022 00:49:12 +0200 Subject: [PATCH 2/2] Respect user choice, remove nation lang string --- resources/lang/en-US.yml | 4 +--- .../palmergames/bukkit/towny/command/TownyAdminCommand.java | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/resources/lang/en-US.yml b/resources/lang/en-US.yml index 457ecc107e..b7f99022a7 100644 --- a/resources/lang/en-US.yml +++ b/resources/lang/en-US.yml @@ -1755,6 +1755,4 @@ msg_comptype_upkeep: 'Upkeep' # Added in 0.155 # Message shown when toggling town upkeep admin setting -msg_town_upkeep_setting_set_to: 'The town %s has had their upkeep setting set to %s.' -# Message shown when toggling nation upkeep admin setting -msg_nation_upkeep_setting_set_to: 'The nation %s has had their upkeep setting set to %s.' +msg_town_upkeep_setting_set_to: 'The town %s has had their upkeep setting set to %s.' \ No newline at end of file diff --git a/src/com/palmergames/bukkit/towny/command/TownyAdminCommand.java b/src/com/palmergames/bukkit/towny/command/TownyAdminCommand.java index 4c802af422..ef4993b5a0 100644 --- a/src/com/palmergames/bukkit/towny/command/TownyAdminCommand.java +++ b/src/com/palmergames/bukkit/towny/command/TownyAdminCommand.java @@ -1335,7 +1335,7 @@ public void parseAdminTownCommand(String[] split) throws TownyException { TownyMessaging.sendMsg(sender, Translatable.of("msg_town_unlimitedclaims_setting_set_to", town.getName(), town.hasUnlimitedClaims())); } else if (split[2].equalsIgnoreCase("upkeep")) { - town.setHasUpkeep(!town.hasUpkeep()); + town.setHasUpkeep(choice.orElse(!town.hasUpkeep())); town.save(); TownyMessaging.sendMsg(sender, Translatable.of("msg_town_upkeep_setting_set_to", town.getName(), town.hasUpkeep())); } else