summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorEvilSeph <evilseph@gmail.com>2012-01-07 19:54:02 -0500
committerEvilSeph <evilseph@gmail.com>2012-01-07 19:54:02 -0500
commitb1815cc6c64b07a67a9749c1c461119ee873d4e0 (patch)
tree3c5028d8ec332dd36ef4f92b16207b976f0786d9 /src/main/java
parent76c23ee5886897a1beced31dbffa15574864e6bb (diff)
downloadbukkit-b1815cc6c64b07a67a9749c1c461119ee873d4e0.tar
bukkit-b1815cc6c64b07a67a9749c1c461119ee873d4e0.tar.gz
bukkit-b1815cc6c64b07a67a9749c1c461119ee873d4e0.tar.lz
bukkit-b1815cc6c64b07a67a9749c1c461119ee873d4e0.tar.xz
bukkit-b1815cc6c64b07a67a9749c1c461119ee873d4e0.zip
Added banlist command. Fixes BUKKIT-373. Thanks md-5!
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/bukkit/command/SimpleCommandMap.java1
-rw-r--r--src/main/java/org/bukkit/command/defaults/BanListCommand.java37
2 files changed, 38 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/command/SimpleCommandMap.java b/src/main/java/org/bukkit/command/SimpleCommandMap.java
index 5965e4d7..5fa0f07a 100644
--- a/src/main/java/org/bukkit/command/SimpleCommandMap.java
+++ b/src/main/java/org/bukkit/command/SimpleCommandMap.java
@@ -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) {
diff --git a/src/main/java/org/bukkit/command/defaults/BanListCommand.java b/src/main/java/org/bukkit/command/defaults/BanListCommand.java
new file mode 100644
index 00000000..b844faed
--- /dev/null
+++ b/src/main/java/org/bukkit/command/defaults/BanListCommand.java
@@ -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");
+ }
+}