Skip to content

Commit

Permalink
- New Command: /ta nation [nationname] kick [towns...]
Browse files Browse the repository at this point in the history
    - Allows admins to remove towns from a nation.
    - Closes #4050.
  • Loading branch information
LlmDl committed Jun 3, 2020
1 parent b8593e4 commit f54acbc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
4 changes: 3 additions & 1 deletion resources/ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4627,4 +4627,6 @@ v0.92.0.11:
- Closes #4045.
- Add javadocs to maven, courtesy of Siris with PR #4049.
- Use mvn clean install to build javadocs.

- New Command: /ta nation [nationname] kick [towns...]
- Allows admins to remove towns from a nation.
- Closes #4050.
10 changes: 5 additions & 5 deletions src/com/palmergames/bukkit/towny/command/NationCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -1723,10 +1723,10 @@ public void nationKick(Player player, String[] names) {
return;
}

nationKick(player, resident, nation, townyUniverse.getDataSource().getTowns(names));
nationKick(player, nation, townyUniverse.getDataSource().getTowns(names));
}

public void nationKick(Player player, Resident resident, Nation nation, List<Town> kicking) {
public static void nationKick(CommandSender sender, Nation nation, List<Town> kicking) {
TownyUniverse townyUniverse = TownyUniverse.getInstance();

ArrayList<Town> remove = new ArrayList<>();
Expand Down Expand Up @@ -1768,17 +1768,17 @@ public void nationKick(Player player, Resident resident, Nation nation, List<Tow
for (Town town : kicking) {
msg.append(town.getName()).append(", ");

TownyMessaging.sendPrefixedTownMessage(town, String.format(TownySettings.getLangString("msg_nation_kicked_by"), player.getName()));
TownyMessaging.sendPrefixedTownMessage(town, String.format(TownySettings.getLangString("msg_nation_kicked_by"), sender.getName()));
}

msg = new StringBuilder(msg.substring(0, msg.length() - 2));
msg = new StringBuilder(String.format(TownySettings.getLangString("msg_nation_kicked"), player.getName(), msg.toString()));
msg = new StringBuilder(String.format(TownySettings.getLangString("msg_nation_kicked"), sender.getName(), msg.toString()));
TownyMessaging.sendPrefixedNationMessage(nation, msg.toString());
townyUniverse.getDataSource().saveNation(nation);

plugin.resetCache();
} else
TownyMessaging.sendErrorMsg(player, TownySettings.getLangString("msg_invalid_name"));
TownyMessaging.sendErrorMsg(sender, TownySettings.getLangString("msg_invalid_name"));
}

private void nationAlly(Player player, String[] split) throws TownyException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public class TownyAdminCommand extends BaseCommand implements CommandExecutor {

private static final List<String> adminNationTabCompletes = Arrays.asList(
"add",
"kick",
"rename",
"delete",
"toggle",
Expand Down Expand Up @@ -1158,6 +1159,7 @@ public void parseAdminNationCommand(String[] split) throws TownyException {
sender.sendMessage(ChatTools.formatCommand(TownySettings.getLangString("admin_sing"), "/townyadmin nation", "new", "[name] [capital]"));
sender.sendMessage(ChatTools.formatCommand(TownySettings.getLangString("admin_sing"), "/townyadmin nation", "[nation]", ""));
sender.sendMessage(ChatTools.formatCommand(TownySettings.getLangString("admin_sing"), "/townyadmin nation", "[nation] add [] .. []", ""));
sender.sendMessage(ChatTools.formatCommand(TownySettings.getLangString("admin_sing"), "/townyadmin nation", "[nation] kick [] .. []", ""));
sender.sendMessage(ChatTools.formatCommand(TownySettings.getLangString("admin_sing"), "/townyadmin nation", "[nation] rename [newname]", ""));
sender.sendMessage(ChatTools.formatCommand(TownySettings.getLangString("admin_sing"), "/townyadmin nation", "[nation] delete", ""));
sender.sendMessage(ChatTools.formatCommand(TownySettings.getLangString("admin_sing"), "/townyadmin nation", "[nation] recheck", ""));
Expand Down Expand Up @@ -1202,6 +1204,10 @@ public void parseAdminNationCommand(String[] split) throws TownyException {
*/
NationCommand.nationAdd(nation, townyUniverse.getDataSource().getTowns(StringMgmt.remArgs(split, 2)));

} else if (split[1].equalsIgnoreCase("kick")) {

NationCommand.nationKick(sender, nation, townyUniverse.getDataSource().getTowns(StringMgmt.remArgs(split, 2)));

} else if (split[1].equalsIgnoreCase("delete")) {
if (!isConsole) {
TownyMessaging.sendMessage(sender, String.format(TownySettings.getLangString("nation_deleted_by_admin"), nation.getName()));
Expand Down

0 comments on commit f54acbc

Please sign in to comment.