    001    package net.minecraft.command;
    002
    003    import java.util.ArrayList;
    004    import java.util.List;
    005    import net.minecraft.server.MinecraftServer;
    006
    007    public 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 var3 = par2ArrayOfStr[par2ArrayOfStr.length - 1];
    048                ArrayList var4 = new ArrayList();
    049                String[] var5 = MinecraftServer.getServer().getAllUsernames();
    050                int var6 = var5.length;
    051
    052                for (int var7 = 0; var7 < var6; ++var7)
    053                {
    054                    String var8 = var5[var7];
    055
    056                    if (!MinecraftServer.getServer().getConfigurationManager().areCommandsAllowed(var8) && doesStringStartWith(var3, var8))
    057                    {
    058                        var4.add(var8);
    059                    }
    060                }
    061
    062                return var4;
    063            }
    064            else
    065            {
    066                return null;
    067            }
    068        }
    069    }