    001package net.minecraft.command;
    002
    003import java.util.ArrayList;
    004import java.util.List;
    005import net.minecraft.server.MinecraftServer;
    006
    007public class CommandServerOp extends CommandBase
    008{
    009    public String getCommandName()
    010    {
    011        return "op";
    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.op.usage", new Object[0]);
    025    }
    026
    027    public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
    028    {
    029        if (par2ArrayOfStr.length == 1 && par2ArrayOfStr[0].length() > 0)
    030        {
    031            MinecraftServer.getServer().getConfigurationManager().addOp(par2ArrayOfStr[0]);
    032            notifyAdmins(par1ICommandSender, "commands.op.success", new Object[] {par2ArrayOfStr[0]});
    033        }
    034        else
    035        {
    036            throw new WrongUsageException("commands.op.usage", new Object[0]);
    037        }
    038    }
    039
    040    /**
    041     * Adds the strings available in this command to the given list of tab completion options.
    042     */
    043    public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
    044    {
    045        if (par2ArrayOfStr.length == 1)
    046        {
    047            String s = par2ArrayOfStr[par2ArrayOfStr.length - 1];
    048            ArrayList arraylist = new ArrayList();
    049            String[] astring1 = MinecraftServer.getServer().getAllUsernames();
    050            int i = astring1.length;
    051
    052            for (int j = 0; j < i; ++j)
    053            {
    054                String s1 = astring1[j];
    055
    056                if (!MinecraftServer.getServer().getConfigurationManager().areCommandsAllowed(s1) && doesStringStartWith(s, s1))
    057                {
    058                    arraylist.add(s1);
    059                }
    060            }
    061
    062            return arraylist;
    063        }
    064        else
    065        {
    066            return null;
    067        }
    068    }
    069}