Solved Experience

Discussion in 'Plugin Development' started by Staartvin, Jan 1, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Staartvin

    I'm trying to give a player certain amount of experience when it respawns.
    Everything works fine, except the part of actually 'giving' the experience.

    I've tried player.setTotalExperience(amount) but I read that you shouldn't use this and I therefore tried player.giveExp(amount). Although this does work, it doesn't update the xp bar properly. When a player tries to enchant something, it can't. Because his/her level is still 0.

    I've tried this custom class: https://github.com/aadnk/Experience...omphenix/xp/rewards/xp/ExperienceManager.java, but that didn't work either.

    Do you guys have any ideas?
     
  2. Offline

    ZeusAllMighty11

    Hmmm I've never tried messing with total experience much, aside from giving myself level 9001 to show off ;P



    I know that on xbox version of Minecraft, it is fine to change the value of totalExperience and set it to a float, and nothing bad can happen unless you mess the hex up :p

    But that's not really relevant



    Where did it say don't use setTotalExperience() ? and why?
     
  3. Offline

    Staartvin

    The page: http://forums.bukkit.org/threads/settotalexperience-does-not-work.103475/

    I find it strange that Bukkit doesn't have working methods for experience. Although they work for a bit, they don't actually update the xpbar?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
  4. Offline

    Tirelessly

    The problem is probably that you're giving it to them when they're dead. Schedule a sync task for like 3 ticks later then set their experience. I had this problem with potioneffects.
     
  5. Offline

    Staartvin

    Hmm, I send it to them in the PlayerRespawnEvent. It ought not to be a problem?
     
  6. Offline

    Tirelessly

    Yeah that's a problem. PlayerRespawnEvent fire before they respawn, that's why you can do e.setRespawnLocation
     
  7. Offline

    Staartvin

    Ah, ok. Thanks!

    It seems to work. Thanks again! :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
Thread Status:
Not open for further replies.

Share This Page