    001package net.minecraft.command;
    002
    003import java.util.List;
    004import net.minecraft.server.MinecraftServer;
    005
    006public class CommandServerBanlist extends CommandBase
    007{
    008    public String getCommandName()
    009    {
    010        return "banlist";
    011    }
    012
    013    /**
    014     * Return the required permission level for this command.
    015     */
    016    public int getRequiredPermissionLevel()
    017    {
    018        return 3;
    019    }
    020
    021    /**
    022     * Returns true if the given command sender is allowed to use this command.
    023     */
    024    public boolean canCommandSenderUseCommand(ICommandSender par1ICommandSender)
    025    {
    026        return (MinecraftServer.getServer().getConfigurationManager().getBannedIPs().isListActive() || MinecraftServer.getServer().getConfigurationManager().getBannedPlayers().isListActive()) && super.canCommandSenderUseCommand(par1ICommandSender);
    027    }
    028
    029    public String getCommandUsage(ICommandSender par1ICommandSender)
    030    {
    031        return par1ICommandSender.translateString("commands.banlist.usage", new Object[0]);
    032    }
    033
    034    public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
    035    {
    036        if (par2ArrayOfStr.length >= 1 && par2ArrayOfStr[0].equalsIgnoreCase("ips"))
    037        {
    038            par1ICommandSender.sendChatToPlayer(par1ICommandSender.translateString("commands.banlist.ips", new Object[] {Integer.valueOf(MinecraftServer.getServer().getConfigurationManager().getBannedIPs().getBannedList().size())}));
    039            par1ICommandSender.sendChatToPlayer(joinNiceString(MinecraftServer.getServer().getConfigurationManager().getBannedIPs().getBannedList().keySet().toArray()));
    040        }
    041        else
    042        {
    043            par1ICommandSender.sendChatToPlayer(par1ICommandSender.translateString("commands.banlist.players", new Object[] {Integer.valueOf(MinecraftServer.getServer().getConfigurationManager().getBannedPlayers().getBannedList().size())}));
    044            par1ICommandSender.sendChatToPlayer(joinNiceString(MinecraftServer.getServer().getConfigurationManager().getBannedPlayers().getBannedList().keySet().toArray()));
    045        }
    046    }
    047
    048    /**
    049     * Adds the strings available in this command to the given list of tab completion options.
    050     */
    051    public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
    052    {
    053        return par2ArrayOfStr.length == 1 ? getListOfStringsMatchingLastWord(par2ArrayOfStr, new String[] {"players", "ips"}): null;
    054    }
    055}