    001    package net.minecraft.src;
    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        public String getCommandUsage(ICommandSender par1ICommandSender)
    015        {
    016            return par1ICommandSender.translateString("commands.op.usage", new Object[0]);
    017        }
    018
    019        public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
    020        {
    021            if (par2ArrayOfStr.length == 1 && par2ArrayOfStr[0].length() > 0)
    022            {
    023                MinecraftServer.getServer().getConfigurationManager().addOp(par2ArrayOfStr[0]);
    024                notifyAdmins(par1ICommandSender, "commands.op.success", new Object[] {par2ArrayOfStr[0]});
    025            }
    026            else
    027            {
    028                throw new WrongUsageException("commands.op.usage", new Object[0]);
    029            }
    030        }
    031
    032        /**
    033         * Adds the strings available in this command to the given list of tab completion options.
    034         */
    035        public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
    036        {
    037            if (par2ArrayOfStr.length == 1)
    038            {
    039                String var3 = par2ArrayOfStr[par2ArrayOfStr.length - 1];
    040                ArrayList var4 = new ArrayList();
    041                String[] var5 = MinecraftServer.getServer().getAllUsernames();
    042                int var6 = var5.length;
    043
    044                for (int var7 = 0; var7 < var6; ++var7)
    045                {
    046                    String var8 = var5[var7];
    047
    048                    if (!MinecraftServer.getServer().getConfigurationManager().areCommandsAllowed(var8) && doesStringStartWith(var3, var8))
    049                    {
    050                        var4.add(var8);
    051                    }
    052                }
    053
    054                return var4;
    055            }
    056            else
    057            {
    058                return null;
    059            }
    060        }
    061    }