Fixed "list" to not show junk in console.

This commit is contained in:
Steven Lawson 2011-09-23 12:46:31 -04:00
parent e16a909668
commit 5c5a0acd18

View File

@ -101,35 +101,43 @@ public class TotalFreedomMod extends JavaPlugin
} }
else if(cmd.getName().equalsIgnoreCase("listreal") || cmd.getName().equalsIgnoreCase("list")) else if(cmd.getName().equalsIgnoreCase("listreal") || cmd.getName().equalsIgnoreCase("list"))
{ {
StringBuilder online = new StringBuilder(); StringBuilder onlineStats = new StringBuilder();
online.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(Bukkit.getOnlinePlayers().length);
online.append(ChatColor.BLUE).append(" out of a maximum ").append(ChatColor.RED).append(Bukkit.getMaxPlayers());
online.append(ChatColor.BLUE).append(" players online.");
sender.sendMessage(online.toString());
StringBuilder onlineUsers = new StringBuilder(); StringBuilder onlineUsers = new StringBuilder();
onlineUsers.append("Connected players: ");
boolean first = true; if (player == null)
for (Player p : Bukkit.getOnlinePlayers())
{ {
if (first) onlineStats.append(String.format("There are %d out of a maximum %d players online.", Bukkit.getOnlinePlayers().length, Bukkit.getMaxPlayers()));
{
first = false; onlineUsers.append("Connected players: ");
} boolean first = true;
else for (Player p : Bukkit.getOnlinePlayers())
{
onlineUsers.append(", ");
}
if (p.isOp())
{
onlineUsers.append(ChatColor.RED).append(p.getName());
}
else
{ {
if (first) first = false;
else onlineUsers.append(", ");
onlineUsers.append(p.getName()); onlineUsers.append(p.getName());
} }
onlineUsers.append(ChatColor.WHITE);
} }
else
{
onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(Bukkit.getOnlinePlayers().length);
onlineStats.append(ChatColor.BLUE).append(" out of a maximum ").append(ChatColor.RED).append(Bukkit.getMaxPlayers());
onlineStats.append(ChatColor.BLUE).append(" players online.");
onlineUsers.append("Connected players: ");
boolean first = true;
for (Player p : Bukkit.getOnlinePlayers())
{
if (first) first = false;
else onlineUsers.append(", ");
if (p.isOp()) onlineUsers.append(ChatColor.RED).append(p.getName());
else onlineUsers.append(p.getName());
onlineUsers.append(ChatColor.WHITE);
}
}
sender.sendMessage(onlineStats.toString());
sender.sendMessage(onlineUsers.toString()); sender.sendMessage(onlineUsers.toString());
return true; return true;