    001    package net.minecraft.src;
    002
    003    import java.util.List;
    004    import net.minecraft.server.MinecraftServer;
    005
    006    public class CommandServerKick extends CommandBase
    007    {
    008        public String getCommandName()
    009        {
    010            return "kick";
    011        }
    012
    013        /**
    014         * Return the required permission level for this command.
    015         */
    016        public int getRequiredPermissionLevel()
    017        {
    018            return 3;
    019        }
    020
    021        public String getCommandUsage(ICommandSender par1ICommandSender)
    022        {
    023            return par1ICommandSender.translateString("commands.kick.usage", new Object[0]);
    024        }
    025
    026        public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
    027        {
    028            if (par2ArrayOfStr.length > 0 && par2ArrayOfStr[0].length() > 1)
    029            {
    030                EntityPlayerMP var3 = MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(par2ArrayOfStr[0]);
    031                String var4 = "Kicked by an operator.";
    032                boolean var5 = false;
    033
    034                if (var3 == null)
    035                {
    036                    throw new PlayerNotFoundException();
    037                }
    038                else
    039                {
    040                    if (par2ArrayOfStr.length >= 2)
    041                    {
    042                        var4 = func_82360_a(par1ICommandSender, par2ArrayOfStr, 1);
    043                        var5 = true;
    044                    }
    045
    046                    var3.playerNetServerHandler.kickPlayerFromServer(var4);
    047
    048                    if (var5)
    049                    {
    050                        notifyAdmins(par1ICommandSender, "commands.kick.success.reason", new Object[] {var3.getEntityName(), var4});
    051                    }
    052                    else
    053                    {
    054                        notifyAdmins(par1ICommandSender, "commands.kick.success", new Object[] {var3.getEntityName()});
    055                    }
    056                }
    057            }
    058            else
    059            {
    060                throw new WrongUsageException("commands.kick.usage", new Object[0]);
    061            }
    062        }
    063
    064        /**
    065         * Adds the strings available in this command to the given list of tab completion options.
    066         */
    067        public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
    068        {
    069            return par2ArrayOfStr.length >= 1 ? getListOfStringsMatchingLastWord(par2ArrayOfStr, MinecraftServer.getServer().getAllUsernames()) : null;
    070        }
    071    }