    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 String getCommandUsage(ICommandSender par1ICommandSender)
    014        {
    015            return par1ICommandSender.translateString("commands.xp.usage", new Object[0]);
    016        }
    017
    018        public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
    019        {
    020            if (par2ArrayOfStr.length > 0)
    021            {
    022                int var4 = parseIntBounded(par1ICommandSender, par2ArrayOfStr[0], 0, 5000);
    023                EntityPlayer var3;
    024
    025                if (par2ArrayOfStr.length > 1)
    026                {
    027                    var3 = this.getPlayer(par2ArrayOfStr[1]);
    028                }
    029                else
    030                {
    031                    var3 = getCommandSenderAsPlayer(par1ICommandSender);
    032                }
    033
    034                var3.addExperience(var4);
    035                notifyAdmins(par1ICommandSender, "commands.xp.success", new Object[] {Integer.valueOf(var4), var3.getEntityName()});
    036            }
    037            else
    038            {
    039                throw new WrongUsageException("commands.xp.usage", new Object[0]);
    040            }
    041        }
    042
    043        /**
    044         * Adds the strings available in this command to the given list of tab completion options.
    045         */
    046        public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
    047        {
    048            return par2ArrayOfStr.length == 2 ? getListOfStringsMatchingLastWord(par2ArrayOfStr, this.getAllUsernames()) : null;
    049        }
    050
    051        protected EntityPlayer getPlayer(String par1Str)
    052        {
    053            EntityPlayerMP var2 = MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(par1Str);
    054
    055            if (var2 == null)
    056            {
    057                throw new PlayerNotFoundException();
    058            }
    059            else
    060            {
    061                return var2;
    062            }
    063        }
    064
    065        protected String[] getAllUsernames()
    066        {
    067            return MinecraftServer.getServer().getAllUsernames();
    068        }
    069    }