Getting player exp after PlayerExpChangeEvent

Discussion in 'Plugin Development' started by colmalle, Aug 6, 2020.

  1. Offline

    colmalle

    Is there any way of getting the player.getExp() and player.getLevel() after the event PlayerExpChangeEvent without waiting 1 tick? because changing the exp after 1 tick makes the exp bar flicker
     
  2. Offline

    KarimAKL

    Just calculate it by adding PlayerExpChangeEvent#getAmount() onto Player#getTotalExperience().

    Why would you do that when the event has a setAmount(int) method?
     
  3. Offline

    colmalle

    First of all the player#getTotalExperience() doesn't show the current amount of the player. It shows the total amount the player has collected. Second of all, I need the player level (Player#getLevel()) and the player's progression (Player#getExp()) after the amount was already added. And there is no Player#addExp(int amount)
     
  4. Offline

    KarimAKL

    Ah, that's my bad. I did find this thread though. You can also take a look at the wiki page.

    There's a giveExp(int) and a giveExpLevels(int).

    Btw, what are you trying to achieve?
     
  5. Offline

    colmalle

    I think that I can just give the amount to the player and then set the amount to 0.
     
  6. Offline

    colmalle

    Okay thank you
     
    Last edited: Aug 8, 2020
  7. Offline

    KarimAKL

  8. Offline

    colmalle

    Nah I just waited a tick and let it flicker. But I might need to do it in the future
     

Share This Page