How to get a player's exp on death?[Solved]

Discussion in 'Plugin Development' started by TechManDylan, Jul 17, 2012.

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

    TechManDylan

    So I was looking at the PlayerDeathEvent and I don't see a way of getting their current level I see you can get it after respawn but I need to get how much exp they have before that :S anybody know a way to do this or a work around?
     
  2. Offline

    r0306

    TechManDylan
    The getExp is part of the player class so you would have to get it from the player, not from the event.
    Code:
    @EventHandler
    public void onDeath(PlayerDeathEvent event)
    {
     
      Player player = event.getPlayer();
     
      float exp = player.getExp();
      int level = player.getLevel();
     
    }
     
    dark navi likes this.
  3. Offline

    dark navi

    Note: I am fairly sure that getExp() return a float from 0 to 1, being the percentage of the EXP bar that is filled.
     
  4. Offline

    TechManDylan

    Cool cool thank a bunch let's see if I can use this new found knowledge to make something useful now XD
     
  5. Offline

    Kodfod

    Nah getExp() gets the ammount of exp (not levels but orbs you get like 1, 5, 50, 100, etc...)
     
  6. Offline

    WarmakerT

    Use: getTotalExperience() instead.
    Check the value you get with getExp() and you'll see why.
     
  7. Offline

    EnvisionRed

    getExp() actually shows the percentage of exp the player has of the amount required to reach the next level.
    When the player levels, the value is reverted to 0. It will rise as the player gathers exp until it reaches 1 at which point the player levels up.
     
  8. Offline

    dark navi

    ZachBora likes this.
  9. Offline

    Kodfod

  10. Offline

    TechManDylan

    Thanks guys I got my plugin working and I plan on posting it up here in a little bit I just wanna make sure no bugs before release or at least try lol
     
Thread Status:
Not open for further replies.

Share This Page