    001    package net.minecraft.src;
    002
    003    import java.util.List;
    004    import java.util.regex.Matcher;
    005    import net.minecraft.server.MinecraftServer;
    006
    007    public class CommandServerPardonIp extends CommandBase
    008    {
    009        public String getCommandName()
    010        {
    011            return "pardon-ip";
    012        }
    013
    014        public int func_82362_a()
    015        {
    016            return 3;
    017        }
    018
    019        /**
    020         * Returns true if the given command sender is allowed to use this command.
    021         */
    022        public boolean canCommandSenderUseCommand(ICommandSender par1ICommandSender)
    023        {
    024            return MinecraftServer.getServer().getConfigurationManager().getBannedIPs().isListActive() && super.canCommandSenderUseCommand(par1ICommandSender);
    025        }
    026
    027        public String getCommandUsage(ICommandSender par1ICommandSender)
    028        {
    029            return par1ICommandSender.translateString("commands.unbanip.usage", new Object[0]);
    030        }
    031
    032        public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
    033        {
    034            if (par2ArrayOfStr.length == 1 && par2ArrayOfStr[0].length() > 1)
    035            {
    036                Matcher var3 = CommandServerBanIp.IPv4Pattern.matcher(par2ArrayOfStr[0]);
    037
    038                if (var3.matches())
    039                {
    040                    MinecraftServer.getServer().getConfigurationManager().getBannedIPs().remove(par2ArrayOfStr[0]);
    041                    notifyAdmins(par1ICommandSender, "commands.unbanip.success", new Object[] {par2ArrayOfStr[0]});
    042                }
    043                else
    044                {
    045                    throw new SyntaxErrorException("commands.unbanip.invalid", new Object[0]);
    046                }
    047            }
    048            else
    049            {
    050                throw new WrongUsageException("commands.unbanip.usage", new Object[0]);
    051            }
    052        }
    053
    054        /**
    055         * Adds the strings available in this command to the given list of tab completion options.
    056         */
    057        public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
    058        {
    059            return par2ArrayOfStr.length == 1 ? getListOfStringsFromIterableMatchingLastWord(par2ArrayOfStr, MinecraftServer.getServer().getConfigurationManager().getBannedIPs().getBannedList().keySet()) : null;
    060        }
    061    }