Skip to content

Commit

Permalink
API: Add TOWNYADMIN_TOWN and TOWNYADMIN_NATION CommandTypes (#6179)
Browse files Browse the repository at this point in the history
* add command types for api

Added two new types for creating subcommands: TOWNYADMIN_TOWN and TOWNYADMIN_NATION which are triggered by /townyadmin town <town_name> and /townyadmin nation <nation_name> respectively

* remove spaces

remove free spaces

* Remove unneeded diffs.

Co-authored-by: LlmDl <llmdlio@gmail.com>
  • Loading branch information
Lemar98 and LlmDl authored Sep 20, 2022
1 parent 99a593b commit 4f886f1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/com/palmergames/bukkit/towny/TownyCommandAddonAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public enum CommandType {
PLOT_TOGGLE,
TOWNY,
TOWNYADMIN,
TOWNYADMIN_TOWN,
TOWNYADMIN_NATION,
TOWNYADMIN_SET,
TOWNYADMIN_TOGGLE,
TOWNYADMIN_RELOAD,
Expand Down
14 changes: 12 additions & 2 deletions src/com/palmergames/bukkit/towny/command/TownyAdminCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,10 @@ else if (args.length == 5 && !args[3].equalsIgnoreCase("jail"))
return getTownyStartingWith(args[3], "t");
default:
if (args.length == 3)
return NameUtil.filterByStart(adminTownTabCompletes, args[2]);
return NameUtil.filterByStart(
TownyCommandAddonAPI.getTabCompletes(
CommandType.TOWNYADMIN_TOWN, adminTownTabCompletes
), args[2]);
}
} else if (args.length == 4 && args[1].equalsIgnoreCase("new")) {
return getTownyStartingWith(args[3], "r");
Expand Down Expand Up @@ -529,7 +532,10 @@ else if (args.length == 6)
return getTownyStartingWith(args[4], "n");
default:
if (args.length == 3)
return NameUtil.filterByStart(adminNationTabCompletes, args[2]);
return NameUtil.filterByStart(
TownyCommandAddonAPI.getTabCompletes(
CommandType.TOWNYADMIN_NATION, adminNationTabCompletes
), args[2]);
}
} else if (args.length == 4 && args[1].equalsIgnoreCase("new")) {
return getTownyStartingWith(args[3], "t");
Expand Down Expand Up @@ -1479,6 +1485,8 @@ public void parseAdminTownCommand(String[] split) throws TownyException {
townyUniverse.getDataSource().mergeTown(town, remainingTown);
TownyMessaging.sendGlobalMessage(Translatable.of("town1_has_merged_with_town2", town, remainingTown));
}).sendTo(sender);
} else if (TownyCommandAddonAPI.hasCommand(CommandType.TOWNYADMIN_TOWN, split[1])) {
TownyCommandAddonAPI.getAddonCommand(CommandType.TOWNYADMIN_TOWN, split[1]).execute(sender, split);
} else {
HelpMenu.TA_TOWN.send(sender);
return;
Expand Down Expand Up @@ -1933,6 +1941,8 @@ else if (split[1].equalsIgnoreCase("rank")) {
TownyMessaging.sendErrorMsg(getSender(), Translatable.of("msg_err_nation_not_enemies_with_2", nation.getName(), enemy.getName()));
} else
TownyMessaging.sendErrorMsg(getSender(), Translatable.of("msg_err_invalid_input", "/ta nation [nation] enemy [add/remove] [nation]"));
} else if (TownyCommandAddonAPI.hasCommand(CommandType.TOWNYADMIN_NATION, split[1])) {
TownyCommandAddonAPI.getAddonCommand(CommandType.TOWNYADMIN_NATION, split[1]).execute(sender, split);
}

} catch (NotRegisteredException | AlreadyRegisteredException | InvalidNameException e) {
Expand Down

0 comments on commit 4f886f1

Please sign in to comment.