Experience Methods not Properly Applying

Discussion in 'Plugin Development' started by stargateanubis14, Jun 4, 2012.

Thread Status:
Not open for further replies.
  1. I have a basic plugin operational, that takes a command (in this case /exp), and does one of 3 things with it:
    /exp --Returns the players experience level
    /exp set [value] --Sets the players experience to a certain amount
    /exp [value] --Adds [value] to the players experience level.


    these are using the getTotalExperience() and setTotalExperience() methods. In and of itself, it works perfectly fine. When i do /exp set 50, and then do /exp, it shows that i have 50 experience...
    However, the experience bar in-game does not update (even after relogging, and restarting the server).
    So, i thought it might be something to do with jumping levels. So i simply set my experience to 1, then to 8, to show a small increase in the bar. However, there were no changes.

    Is this a known bug, or depreciated methods? My primary goal at this point, is to be able to assign x number of experience points to a player, and or remove them, and have it display properly in-game.

    Ok... since the experience was setting properly, and it didn't appear that the methods were wrong, i looked into the bar itself.

    I'll post what i found in case anyone else needs to see what the problem is.
    Basically, the experience bar in mc, is based on your LEVEL, and your progress to your next level (which is a percentage). For some reason, i dont know why, its this way, but the experience, and your level, is separated completely apart. If you are going to manually change the experience, make sure that you also calculate the level (and progress to next level), if you want it to display properly to the player.

    ~Solved

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 26, 2016
  2. There's also ExperienceUtils ( Do a search on Resources) it has a lot of bug fixes for giving an taking exp.
     
  3. Offline

    dark navi

    For anyone who was confused, the setExp() method set the percent of EXP bar is filled, from 0.00-1.00.
     
  4. yeah, i saw that after i finished working on my stuff... tis a pretty good resource for this sloppy subject :D

    But i am modifying the experience internally... no external access for users :)
     
  5. Offline

    desht

    I'm the author of the ExperienceUtils thread (my latest iteration is actually called ExperienceManager - slightly rewritten from the original, but it's in the same thread: http://forums.bukkit.org/threads/ex...giving-taking-exp-a-bit-more-intuitive.54450/ & read down to the end of the thread).

    Anyway, it's not a plugin - it's a standalone class that you're free to incorporate into your own plugins. So there's no question of any kind of external user access.
     
Thread Status:
Not open for further replies.

Share This Page