    001package net.minecraft.command;
    002
    003import java.util.List;
    004import net.minecraft.entity.player.EntityPlayerMP;
    005import net.minecraft.server.MinecraftServer;
    006
    007public 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 entityplayermp = MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(par2ArrayOfStr[0]);
    032            String s = "Kicked by an operator.";
    033            boolean flag = false;
    034
    035            if (entityplayermp == null)
    036            {
    037                throw new PlayerNotFoundException();
    038            }
    039            else
    040            {
    041                if (par2ArrayOfStr.length >= 2)
    042                {
    043                    s = func_82360_a(par1ICommandSender, par2ArrayOfStr, 1);
    044                    flag = true;
    045                }
    046
    047                entityplayermp.playerNetServerHandler.kickPlayerFromServer(s);
    048
    049                if (flag)
    050                {
    051                    notifyAdmins(par1ICommandSender, "commands.kick.success.reason", new Object[] {entityplayermp.getEntityName(), s});
    052                }
    053                else
    054                {
    055                    notifyAdmins(par1ICommandSender, "commands.kick.success", new Object[] {entityplayermp.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}