    001    package net.minecraft.src;
    002
    003    import java.util.List;
    004    import net.minecraft.server.MinecraftServer;
    005
    006    public class CommandXP extends CommandBase
    007    {
    008        public String getCommandName()
    009        {
    010            return "xp";
    011        }
    012
    013        public int func_82362_a()
    014        {
    015            return 2;
    016        }
    017
    018        public String getCommandUsage(ICommandSender par1ICommandSender)
    019        {
    020            return par1ICommandSender.translateString("commands.xp.usage", new Object[0]);
    021        }
    022
    023        public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
    024        {
    025            if (par2ArrayOfStr.length <= 0)
    026            {
    027                throw new WrongUsageException("commands.xp.usage", new Object[0]);
    028            }
    029            else
    030            {
    031                String var4 = par2ArrayOfStr[0];
    032                boolean var5 = var4.endsWith("l") || var4.endsWith("L");
    033
    034                if (var5 && var4.length() > 1)
    035                {
    036                    var4 = var4.substring(0, var4.length() - 1);
    037                }
    038
    039                int var6 = parseInt(par1ICommandSender, var4);
    040                boolean var7 = var6 < 0;
    041
    042                if (var7)
    043                {
    044                    var6 *= -1;
    045                }
    046
    047                EntityPlayerMP var3;
    048
    049                if (par2ArrayOfStr.length > 1)
    050                {
    051                    var3 = func_82359_c(par1ICommandSender, par2ArrayOfStr[1]);
    052                }
    053                else
    054                {
    055                    var3 = getCommandSenderAsPlayer(par1ICommandSender);
    056                }
    057
    058                if (var5)
    059                {
    060                    if (var7)
    061                    {
    062                        var3.func_82242_a(-var6);
    063                        notifyAdmins(par1ICommandSender, "commands.xp.success.negative.levels", new Object[] {Integer.valueOf(var6), var3.getEntityName()});
    064                    }
    065                    else
    066                    {
    067                        var3.func_82242_a(var6);
    068                        notifyAdmins(par1ICommandSender, "commands.xp.success.levels", new Object[] {Integer.valueOf(var6), var3.getEntityName()});
    069                    }
    070                }
    071                else
    072                {
    073                    if (var7)
    074                    {
    075                        throw new WrongUsageException("commands.xp.failure.widthdrawXp", new Object[0]);
    076                    }
    077
    078                    var3.addExperience(var6);
    079                    notifyAdmins(par1ICommandSender, "commands.xp.success", new Object[] {Integer.valueOf(var6), var3.getEntityName()});
    080                }
    081            }
    082        }
    083
    084        /**
    085         * Adds the strings available in this command to the given list of tab completion options.
    086         */
    087        public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
    088        {
    089            return par2ArrayOfStr.length == 2 ? getListOfStringsMatchingLastWord(par2ArrayOfStr, this.getAllUsernames()) : null;
    090        }
    091
    092        protected String[] getAllUsernames()
    093        {
    094            return MinecraftServer.getServer().getAllUsernames();
    095        }
    096
    097        public boolean func_82358_a(int par1)
    098        {
    099            return par1 == 1;
    100        }
    101    }