mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 17:57:34 +01:00
Added banlist command. Fixes BUKKIT-373. Thanks md-5!
By: EvilSeph <evilseph@gmail.com>
This commit is contained in:
parent
d97df0f9dc
commit
0f21027498
@ -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) {
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user