* @return
*/
public static Boolean run(CommandSender sender, String alias, String[] args) {
Boolean hasPerms = true;
if (sender instanceof Player) {
Player player = (Player) sender;
if (Utils.checkCommandSpam(player, "cex_online")){
return true;
}
hasPerms = Permissions.checkPerms(player, "cex.online");
}
// permissions ok, list players
if (hasPerms) {
if (args.length == 0) {
ArrayList<String> players = new ArrayList<String>();
for (Player player : Bukkit.getOnlinePlayers()){
// Determine whether or not to show the player
boolean addPlayer;
if (Common.invisiblePlayers.contains(player.getName())){
if (sender.hasPermission("cex.online.hidden") || sender.getName().equalsIgnoreCase(player.getName())){
addPlayer = true;
} else {
addPlayer = false;
}
} else {
addPlayer = true;
}
// Using the method above, choose whether or not to add the player
if (addPlayer){
String hiddenPrefix = ChatColor.AQUA + "#####onlinePlayerHidden#####[" + ChatColor.YELLOW;
players.add((Common.isInvisible(player.getName()) ? hiddenPrefix: "#####[") + Nicknames.getNick(player.getName()));
}
}
LogHelper.showInfo("onlinePlayers#####[(" + players.size() + "/" + Bukkit.getServer().getMaxPlayers() + "): " + ChatColor.YELLOW + "#####" + Utils.implode(players, ChatColor.AQUA + ", " + ChatColor.YELLOW), sender);
} else {
// check if a given player is online
Player p = Bukkit.getServer().getPlayer(args[0]);
if (p == null || Common.invisiblePlayers.contains(p.getName())) {
LogHelper.showInfo("[" + Nicknames.getNick(args[0]) + " #####isOffline", sender);
} else {
LogHelper.showInfo("[" + Nicknames.getNick(p.getName()) + " #####isOnline", sender);
}
}
}
return true;