    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        /**
    015         * Returns true if the given command sender is allowed to use this command.
    016         */
    017        public boolean canCommandSenderUseCommand(ICommandSender par1ICommandSender)
    018        {
    019            return MinecraftServer.getServer().getConfigurationManager().getBannedIPs().isListActive() && super.canCommandSenderUseCommand(par1ICommandSender);
    020        }
    021
    022        public String getCommandUsage(ICommandSender par1ICommandSender)
    023        {
    024            return par1ICommandSender.translateString("commands.unbanip.usage", new Object[0]);
    025        }
    026
    027        public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
    028        {
    029            if (par2ArrayOfStr.length == 1 && par2ArrayOfStr[0].length() > 1)
    030            {
    031                Matcher var3 = CommandServerBanIp.IPv4Pattern.matcher(par2ArrayOfStr[0]);
    032
    033                if (var3.matches())
    034                {
    035                    MinecraftServer.getServer().getConfigurationManager().getBannedIPs().remove(par2ArrayOfStr[0]);
    036                    notifyAdmins(par1ICommandSender, "commands.unbanip.success", new Object[] {par2ArrayOfStr[0]});
    037                }
    038                else
    039                {
    040                    throw new SyntaxErrorException("commands.unbanip.invalid", new Object[0]);
    041                }
    042            }
    043            else
    044            {
    045                throw new WrongUsageException("commands.unbanip.usage", new Object[0]);
    046            }
    047        }
    048
    049        /**
    050         * Adds the strings available in this command to the given list of tab completion options.
    051         */
    052        public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
    053        {
    054            return par2ArrayOfStr.length == 1 ? getListOfStringsFromIterableMatchingLastWord(par2ArrayOfStr, MinecraftServer.getServer().getConfigurationManager().getBannedIPs().getBannedList().keySet()) : null;
    055        }
    056    }