public List<String> getBannedPlayers() throws APIException { List<String> a = new ArrayList<String>(); for (OfflinePlayer p : Server.getBannedPlayers()) { a.add(p.getName()); } return a; }
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 List<OfflinePlayer> opList() { List<OfflinePlayer> ops = new ArrayList<OfflinePlayer>(); for (OfflinePlayer p : Bukkit.getOfflinePlayers()) { if (p.isOp()) { ops.add(p); } } return ops; }
public List<OfflinePlayer> getOfflinePlayers() { List<OfflinePlayer> o = new ArrayList<OfflinePlayer>(); List<String> online = getPlayerNames(); for (OfflinePlayer p : Server.getOfflinePlayers()) { if (!online.contains(p.getName())) { o.add(p); } } return o; }
public List<String> getOfflinePlayerNames() { List<String> names = new ArrayList<String>(); List<String> online = getPlayerNames(); for (OfflinePlayer p : Server.getOfflinePlayers()) { if (!online.contains(p.getName())) { names.add(p.getName()); } } return names; }
public boolean deop(String playerName) { try { OfflinePlayer p = Bukkit.getOfflinePlayer(playerName); if (p.isOnline()) { p.getPlayer().sendMessage("You are no longer OP"); } p.setOp(false); return true; } catch (Exception e) { return false; } }
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."); }
@Override public boolean equals(Object obj) { if (!(obj instanceof OfflinePlayer)) { return false; } OfflinePlayer other = (OfflinePlayer) obj; if ((this.getName() == null) || (other.getName() == null)) { return false; } boolean nameEquals = this.getName().equalsIgnoreCase(other.getName()); boolean idEquals = true; if (other instanceof CraftPlayer) { idEquals = this.getEntityId() == ((CraftPlayer) other).getEntityId(); } return nameEquals && idEquals; }
@Override public OfflinePlayer[] getOfflinePlayers() { Set<OfflinePlayer> result = new HashSet<>(); Set<UUID> uuids = new HashSet<>(); // add the currently online players for (World world : getWorlds()) { for (Player player : world.getPlayers()) { result.add(player); uuids.add(player.getUniqueId()); } } // add all offline players that aren't already online for (OfflinePlayer offline : getPlayerDataService().getOfflinePlayers()) { if (!uuids.contains(offline.getUniqueId())) { result.add(offline); uuids.add(offline.getUniqueId()); } } return result.toArray(new OfflinePlayer[result.size()]); }
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 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()); } } }