Xp events

Discussion in 'Plugin Development' started by GRANTSWIM4, Jan 5, 2013.

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

    GRANTSWIM4

    Im am working on a plugin how do i check the xp of a player when they pick up xp


    thanks,
    GRANTSWIM4
     
  2. Offline

    hockeygoalie5

    Read up on Bukkit's events. The name of the event you want is PlayExpChangeEvent, and contains the method getAmount() which returns how much the player has picked up. To get their current xp, get the player involved in the event, then get their xp. To get the xp they'll have after they pick up the xp, add their current xp to how much they pick up.
     
  3. Offline

    GRANTSWIM4

    Can you show me how it looks
     
  4. Offline

    hockeygoalie5

    Code:
     
    @EventHandler
    public void onPlayerExpChange(PlayerExpChangeEvent e) {
        int xp = e.getAmount(); // Xp picked up
        int currentXp = e.getPlayer().getExpToLevel(); // Player's xp before pick up
        int getAfterXp = currentXp + xp; // Player's xp after pick up
    }
    
     
    piepiepie likes this.
  5. Offline

    GRANTSWIM4

    Thanks
     
Thread Status:
Not open for further replies.

Share This Page