private void parseTownCommand(Player player, String[] split) {
if (split.length == 0)
try {
Resident resident = TownyUniverse.getDataSource().getResident(player.getName());
Town town = resident.getTown();
TownyMessaging.sendMessage(player, TownyFormatter.getStatus(town));
} catch (NotRegisteredException x) {
TownyMessaging.sendErrorMsg(player, TownySettings.getLangString("msg_err_dont_belong_town"));
}
else if (split[0].equalsIgnoreCase("?") || split[0].equalsIgnoreCase("help"))
for (String line : output)
player.sendMessage(line);
else if (split[0].equalsIgnoreCase("here"))
showTownStatusHere(player);
else if (split[0].equalsIgnoreCase("list"))
listTowns(player);
else if (split[0].equalsIgnoreCase("new")) {
if (split.length == 1)
TownyMessaging.sendErrorMsg(player, TownySettings.getLangString("msg_specify_name"));
else if (split.length == 2)
newTown(player, split[1], player.getName());
else
// TODO: Check if player is an admin
newTown(player, split[1], split[2]);
} else if (split[0].equalsIgnoreCase("leave")) {
townLeave(player);
} else if (split[0].equalsIgnoreCase("withdraw")) {
if (split.length == 2)
try {
townWithdraw(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"), "/town withdraw"));
} else if (split[0].equalsIgnoreCase("deposit")) {
if (split.length == 2)
try {
townDeposit(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"), "/town deposit"));
} else {
String[] newSplit = StringMgmt.remFirstArg(split);
if (split[0].equalsIgnoreCase("set"))
townSet(player, newSplit);
else if (split[0].equalsIgnoreCase("buy"))
townBuy(player, newSplit);
else if (split[0].equalsIgnoreCase("toggle"))
townToggle(player, newSplit);
else if (split[0].equalsIgnoreCase("mayor"))
townMayor(player, newSplit);
else if (split[0].equalsIgnoreCase("assistant"))
townAssistant(player, newSplit);
else if (split[0].equalsIgnoreCase("spawn"))
townSpawn(player, newSplit);
else if (split[0].equalsIgnoreCase("delete"))
townDelete(player, newSplit);
else if (split[0].equalsIgnoreCase("join"))
parseTownJoin(player, newSplit);
else if (split[0].equalsIgnoreCase("add"))
townAdd(player, null, newSplit);
else if (split[0].equalsIgnoreCase("kick"))
townKick(player, newSplit);
else if (split[0].equalsIgnoreCase("claim"))
parseTownClaimCommand(player, newSplit);
else if (split[0].equalsIgnoreCase("unclaim"))
parseTownUnclaimCommand(player, newSplit);
else if (split[0].equalsIgnoreCase("online")) {
try {
Resident resident = TownyUniverse.getDataSource().getResident(player.getName());
Town town = resident.getTown();
TownyMessaging.sendMessage(player, TownyFormatter.getFormattedOnlineResidents(plugin, TownySettings.getLangString("msg_town_online"), town));
} catch (NotRegisteredException x) {
TownyMessaging.sendErrorMsg(player, TownySettings.getLangString("msg_err_dont_belong_town"));
}
} else
try {
Town town = TownyUniverse.getDataSource().getTown(split[0]);
TownyMessaging.sendMessage(player, TownyFormatter.getStatus(town));
} catch (NotRegisteredException x) {
TownyMessaging.sendErrorMsg(player, String.format(TownySettings.getLangString("msg_err_not_registered_1"), split[0]));
}
}