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