public void removePlayerFromTown(String playerName) { if (localSender.isConsole()) { localSender.notifyConsoleNotSupported(); return; } if (!localSender.hasMayoralPermissions()) { localSender.notifyInsufPermissions(); return; } OfflinePlayer removeMe = server.getOfflinePlayer(playerName); Town removeFrom = localSender.getActiveTown(); if (!removeMe.hasPlayedBefore()) { localSender.sendMessage( ERR + "No player named '" + playerName + "' has ever played on this server."); return; } if (removeFrom == null) { localSender.notifyActiveTownNotSet(); return; } if (!removeFrom.playerIsResident(removeMe)) { localSender.sendMessage( ERR + removeMe.getName() + " is not a resident of " + removeFrom.getTownName() + "."); return; } if (removeFrom.playerIsMayor(removeMe)) { localSender.sendMessage(ERR + "A mayor cannot be removed from his own town."); return; } if (removeFrom.playerIsAssistant(removeMe) && !localSender.hasExternalPermissions(Perms.ADMIN.toString()) && !removeFrom.playerIsMayor(localSender.getPlayer())) { localSender.sendMessage( ERR + "Only the mayor or admins can remove assistants from the town."); return; } localSender.getActiveTown().removePlayer(removeMe); Town.recursivelyRemovePlayerFromTown(removeMe, removeFrom); localSender.sendMessage("\"" + playerName + "\" was removed from the town."); Player onlinePlayer = removeMe.getPlayer(); if (onlinePlayer != null) onlinePlayer.sendMessage( ChatColor.DARK_RED + "You have been removed from " + removeFrom.getTownName() + " by " + localSender.getPlayer().getName()); }
public void demoteFromAssistant(String playerName) { if (localSender.isConsole()) { localSender.notifyConsoleNotSupported(); return; } Town t = localSender.getActiveTown(); OfflinePlayer p = server.getOfflinePlayer(playerName); if (t == null) { localSender.notifyActiveTownNotSet(); return; } if (!(localSender.hasExternalPermissions(Perms.ADMIN.toString()) || t.playerIsMayor(localSender.getPlayer()))) { localSender.notifyInsufPermissions(); return; } if (!p.hasPlayedBefore()) { localSender.sendMessage(ERR + playerName + " has never played on this server before."); return; } if (!t.playerIsResident(p)) { localSender.sendMessage(ERR + playerName + " is not a resident of " + t.getTownName() + "."); return; } if (t.removeAssistant(p)) { localSender.sendMessage(p.getName() + " has been demoted."); if (p.isOnline()) p.getPlayer() .sendMessage( ChatColor.DARK_RED + "You are no longer an assistant mayor for " + t.getTownName()); for (String territName : t.getTerritoriesCollection()) { townManager.getTerritory(territName).removePlayer(p); } } else localSender.sendMessage(ERR + p.getName() + " is not an assistant in this town."); }
public void promoteToAssistant(String playerName) { if (localSender.isConsole()) { localSender.notifyConsoleNotSupported(); return; } Town t = localSender.getActiveTown(); if (t == null) { localSender.notifyActiveTownNotSet(); return; } if (!(localSender.hasExternalPermissions(Perms.ADMIN.toString()) || t.playerIsMayor(localSender.getPlayer()))) { localSender.notifyInsufPermissions(); return; } OfflinePlayer p = server.getOfflinePlayer(playerName); if (!p.hasPlayedBefore()) { localSender.sendMessage(ERR + playerName + " has never played on this server before."); return; } if (t.playerIsMayor(p)) { localSender.sendMessage(ERR + "That player is already the mayor of the town."); return; } if (!t.playerIsResident(p)) { localSender.sendMessage(ERR + p.getName() + " is not a resident of " + t.getTownName() + "."); return; } if (t.addAssistant(p)) { for (String territName : t.getTerritoriesCollection()) { townManager.getTerritory(territName).addPlayer(p); } localSender.sendMessage( playerName + " has been promoted to an assistant of " + t.getTownName() + "."); if (p.isOnline()) p.getPlayer().sendMessage("You are now an Assistant Mayor of " + t.getTownName()); } else localSender.sendMessage(ERR + playerName + " is already an assistant in this town."); }
public void invitePlayerToTown(String invitee) { if (localSender.isConsole()) { localSender.notifyConsoleNotSupported(); return; } if (!localSender.hasMayoralPermissions()) { localSender.notifyInsufPermissions(); return; } Town t = localSender.getActiveTown(); if (t == null) { localSender.notifyActiveTownNotSet(); return; } if (t.usesEconomyJoins()) { localSender.sendMessage(t.getTownName() + " doesn't use the invitation system."); return; } OfflinePlayer p = server.getOfflinePlayer(invitee); if (!p.isOnline() && !p.hasPlayedBefore()) { localSender.sendMessage(ERR + invitee + " has never played on this server before."); return; } if (!MCTConfig.PLAYERS_CAN_JOIN_MULTIPLE_TOWNS.getBoolean() && townManager.playerIsAlreadyInATown(p)) { localSender.sendMessage(ERR + p.getName() + " is already in a town."); return; } if (t.playerIsResident(p)) { localSender.sendMessage(ERR + p.getName() + " is already a member of " + t.getTownName()); return; } if (joinManager.getIssuedInvitesForTown(t).contains(p.getName())) { localSender.sendMessage(ERR + p.getName() + " is already invited to join " + t.getTownName()); return; } for (Player pl : Bukkit.getOnlinePlayers()) { if (pl.getName().equalsIgnoreCase(p.getName()) && !pl.getName().equals(p.getName())) { localSender.sendMessage( INFO + "NOTE: You invited " + p.getName() + ", did you mean to invite " + pl.getName() + "? (Names are CaSe SeNsItIvE!)"); } } if (joinManager.requestExists(p.getName(), t)) { t.addPlayer(p); if (p.isOnline()) p.getPlayer().sendMessage("You have joined " + t.getTownName() + "!"); broadcastTownJoin(t, p.getName()); joinManager.clearRequest(p.getName(), t); } else { joinManager.invitePlayerToTown(p.getName(), t); localSender.sendMessage( SUCC + p.getName() + " has been invited to join " + t.getTownName() + "."); if (p.isOnline()) { p.getPlayer() .sendMessage( ChatColor.DARK_GREEN + "You have been invited to join the town " + t.getTownName() + "!"); p.getPlayer() .sendMessage(ChatColor.DARK_GREEN + "To join, type /mct join " + t.getTownName()); } } }