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();
if (player == null)
{
onlineStats.append(String.format("There are %d out of a maximum %d players online.", Bukkit.getOnlinePlayers().length, Bukkit.getMaxPlayers()));
onlineUsers.append("Connected players: "); onlineUsers.append("Connected players: ");
boolean first = true; boolean first = true;
for (Player p : Bukkit.getOnlinePlayers()) for (Player p : Bukkit.getOnlinePlayers())
{ {
if (first) if (first) first = false;
{ else onlineUsers.append(", ");
first = false;
}
else
{
onlineUsers.append(", ");
}
if (p.isOp())
{
onlineUsers.append(ChatColor.RED).append(p.getName());
}
else
{
onlineUsers.append(p.getName()); onlineUsers.append(p.getName());
} }
}
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); onlineUsers.append(ChatColor.WHITE);
} }
}
sender.sendMessage(onlineStats.toString());
sender.sendMessage(onlineUsers.toString()); sender.sendMessage(onlineUsers.toString());
return true; return true;