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