Added banlist command. Fixes BUKKIT-373. Thanks md-5!

By: EvilSeph <evilseph@gmail.com>
This commit is contained in:
Bukkit/Spigot 2012-01-07 19:54:02 -05:00
parent d97df0f9dc
commit 0f21027498
2 changed files with 38 additions and 0 deletions

View File

@ -42,6 +42,7 @@ public class SimpleCommandMap implements CommandMap {
fallbackCommands.add(new HelpCommand());
fallbackCommands.add(new ExpCommand());
fallbackCommands.add(new ToggleDownfallCommand());
fallbackCommands.add(new BanListCommand());
}
public SimpleCommandMap(final Server server) {

View File

@ -0,0 +1,37 @@
package org.bukkit.command.defaults;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
public class BanListCommand extends VanillaCommand {
public BanListCommand() {
super("banlist");
this.description = "View all players banned from this server";
this.usageMessage = "/banlist";
this.setPermission("bukkit.command.ban.list");
}
@Override
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
if (!testPermission(sender)) return true;
StringBuilder message = new StringBuilder().append(ChatColor.GRAY).append("Ban list:");
int count = 0;
for (OfflinePlayer p : Bukkit.getServer().getBannedPlayers()){
if (count++ > 0) {
message.append(", ");
}
message.append(p.getName());
}
sender.sendMessage(message.toString());
return true;
}
@Override
public boolean matches(String input) {
return input.startsWith("banlist ") || input.equalsIgnoreCase("banlist");
}
}