String nationCom = "/nation";
if (split.length == 0)
try {
Resident resident = TownyUniverse.getDataSource().getResident(player.getName());
Town town = resident.getTown();
Nation nation = town.getNation();
TownyMessaging.sendMessage(player, TownyFormatter.getStatus(nation));
} catch (NotRegisteredException x) {
TownyMessaging.sendErrorMsg(player, TownySettings.getLangString("msg_err_dont_belong_nation"));
}
else if (split[0].equalsIgnoreCase("?"))
for (String line : nation_help)
player.sendMessage(line);
else if (split[0].equalsIgnoreCase("list"))
listNations(player);
else if (split[0].equalsIgnoreCase("new")) {
// TODO: Make an overloaded function
// newNation(Player,String,Town)
if (split.length == 1)
TownyMessaging.sendErrorMsg(player, TownySettings.getLangString("msg_specify_nation_name"));
else if (split.length == 2)
try { // TODO: Make sure of the error catching
Resident resident = TownyUniverse.getDataSource().getResident(player.getName());
if (!resident.isMayor() && !resident.getTown().hasAssistant(resident))
throw new TownyException(TownySettings.getLangString("msg_peasant_right"));
newNation(player, split[1], resident.getTown().getName());
} catch (TownyException x) {
TownyMessaging.sendErrorMsg(player, x.getMessage());
}
else
// TODO: Check if player is an admin
newNation(player, split[1], split[2]);
} else if (split[0].equalsIgnoreCase("leave"))
nationLeave(player);
else if (split[0].equalsIgnoreCase("withdraw")) {
if (split.length == 2)
try {
nationWithdraw(player, Integer.parseInt(split[1].trim()));
} catch (NumberFormatException e) {
TownyMessaging.sendErrorMsg(player, TownySettings.getLangString("msg_error_must_be_int"));
}
else
TownyMessaging.sendErrorMsg(player, String.format(TownySettings.getLangString("msg_must_specify_amnt"), nationCom));
} else if (split[0].equalsIgnoreCase("deposit")) {
if (split.length == 2)
try {
nationDeposit(player, Integer.parseInt(split[1].trim()));
} catch (NumberFormatException e) {
TownyMessaging.sendErrorMsg(player, TownySettings.getLangString("msg_error_must_be_int"));
}
else
TownyMessaging.sendErrorMsg(player, String.format(TownySettings.getLangString("msg_must_specify_amnt"), nationCom + " deposit"));
} else {
String[] newSplit = StringMgmt.remFirstArg(split);
if (split[0].equalsIgnoreCase("king"))
nationKing(player, newSplit);
else if (split[0].equalsIgnoreCase("add"))
nationAdd(player, newSplit);
else if (split[0].equalsIgnoreCase("kick"))
nationKick(player, newSplit);
else if (split[0].equalsIgnoreCase("assistant"))
nationAssistant(player, newSplit);
else if (split[0].equalsIgnoreCase("set"))
nationSet(player, newSplit);
else if (split[0].equalsIgnoreCase("toggle"))
nationToggle(player, newSplit);
else if (split[0].equalsIgnoreCase("ally"))
nationAlly(player, newSplit);
else if (split[0].equalsIgnoreCase("enemy"))
nationEnemy(player, newSplit);
else if (split[0].equalsIgnoreCase("delete"))
nationDelete(player, newSplit);
else if (split[0].equalsIgnoreCase("online")) {
try {
Resident resident = TownyUniverse.getDataSource().getResident(player.getName());
Town town = resident.getTown();
Nation nation = town.getNation();
TownyMessaging.sendMessage(player, TownyFormatter.getFormattedOnlineResidents(plugin, TownySettings.getLangString("msg_nation_online"), nation));
} catch (NotRegisteredException x) {
TownyMessaging.sendErrorMsg(player, TownySettings.getLangString("msg_err_dont_belong_nation"));
}
} else