Solved Total Experience broken?

Discussion in 'Spigot Plugin Development' started by Leniency, Oct 5, 2016.

Thread Status:
Not open for further replies.
  1. So, while testing I found out that using the totalExperience methods, if you subtract some experience from a player it does not change their Xp. My code:

    Code (Text):
    if (p.getTotalExperience() < 50000) {
                    p.sendMessage("Not enough xp");
    Does anyone know what is causing this and how to fix it?
  2. What do you mean? When I use something like this
    Code (Text):
    int exp = player.getTotalExperience();
    and then display the exp in a message to the player. It works fine? I even tried subtracting the xp and changing it. What plugin are u using to subtract the xp?
  3. use p.getExp()
  4. getTotalExperience may be returning the amount they have EVER collected. Try using what they said above, getExp() ect
  5. I did a little search and it's not only me. If you see on bukkit forums few other people have had the same issue. I'll do some more research and try to fix it.
    pretty sure that returns their xp bar amount.
    I will look in the javadocs for an answer.
    • Like Like x 1
  6. Be aware that Player#getXP() is different from Player#getLevel()
  7. I know how xp works, dw :p
    this is what I need, thank you :D
    • Like Like x 1
Thread Status:
Not open for further replies.