    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        public String getCommandUsage(ICommandSender par1ICommandSender)
    014        {
    015            return par1ICommandSender.translateString("commands.kick.usage", new Object[0]);
    016        }
    017
    018        public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
    019        {
    020            if (par2ArrayOfStr.length > 0 && par2ArrayOfStr[0].length() > 1)
    021            {
    022                EntityPlayerMP var3 = MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(par2ArrayOfStr[0]);
    023                String var4 = "Kicked by an operator.";
    024                boolean var5 = false;
    025
    026                if (var3 == null)
    027                {
    028                    throw new PlayerNotFoundException();
    029                }
    030                else
    031                {
    032                    if (par2ArrayOfStr.length >= 2)
    033                    {
    034                        var4 = joinString(par2ArrayOfStr, 1);
    035                        var5 = true;
    036                    }
    037
    038                    var3.playerNetServerHandler.kickPlayerFromServer(var4);
    039
    040                    if (var5)
    041                    {
    042                        notifyAdmins(par1ICommandSender, "commands.kick.success.reason", new Object[] {var3.getEntityName(), var4});
    043                    }
    044                    else
    045                    {
    046                        notifyAdmins(par1ICommandSender, "commands.kick.success", new Object[] {var3.getEntityName()});
    047                    }
    048                }
    049            }
    050            else
    051            {
    052                throw new WrongUsageException("commands.kick.usage", new Object[0]);
    053            }
    054        }
    055
    056        /**
    057         * Adds the strings available in this command to the given list of tab completion options.
    058         */
    059        public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
    060        {
    061            return par2ArrayOfStr.length >= 1 ? getListOfStringsMatchingLastWord(par2ArrayOfStr, MinecraftServer.getServer().getAllUsernames()) : null;
    062        }
    063    }