Solved updating xp client-side?

Discussion in 'Spigot Plugin Development' started by Dramatically, May 21, 2017.

Thread Status:
Not open for further replies.
  1. So I use this:
    Code (Text):

    player.giveExp(-10000);
     
    to remove certain exp from a player as other methods do not work Player#setTotalExperience
    , it works, because when I try /exp it says the amount I should have but my exp bar remains the same , the level that shows up does not change? How do I fix this?
     
  2. Working with exp can be tricky and extremely frustrating, we can both agree there.

    However, if you want to alter the player's experience, and at the same time have it updated at the exp bar: you might want to have a look at how I did it: https://github.com/ExpDev07/Experie...expcommand/events/CommandPreProcessEvent.java (note that this is pretty old code).

    By using Player#setLevel(Player#getLevel()) you might be able to force an update.
     
  3. hmm... Thanks, was it you that made ExperienceManager? I may just use that api or use your method, it appears to me that your method does not work, http://prntscr.com/fad49i <------
     
  4. My code now:
    Code (Text):

            player.giveExp(-5000);

                            player.updateInventory();

                            player.setLevel(player.getLevel());
     
    @ExpDev
     
    #4 Dramatically, May 21, 2017
    Last edited: May 21, 2017
  5. Nvm i fixed it with essentials's api for it
     
Thread Status:
Not open for further replies.