Changing xp needed to level up

Discussion in 'Plugin Development' started by MCCoding, Sep 6, 2013.

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

    MCCoding

    Is there a way to change the xp needed to level up, for example lets say it take 12 xp to go from level one to level 2 is there a way i can change that so you need 50xp to go to level 2 etc?
     
  2. Offline

    Musaddict

    I don't think so. I'm pretty sure that is all hard coded into the client. What you can do instead is add a multiplier to any XP picked up. I'm not at my home computer at the moment, so I can't say what the event would be or what the method would be, so allow me to use some poorly devised fictional events and functions here. Anyone tuning in, please feel free to expand my idea as IDK how valid this is without an IDE in front of me:
    Code:java
    1. //XP Pickup Event
    2. Player p = event.getPlayer();
    3. Double multX = 3.0;
    4. Double toAddXp = p.getPickedUpXp() * (multX -1);
    5. p.setXp(p.getXp() + toAddXp);

    Because I'm pretty sure you can't directly alter how much you pick up, I designed this event so that it adds a certain amount of XP to the total XP picked. This addition then reflects the full "multiplied" value of XP you want.

    Example: If the player picked up 1 xp, but you want to multiply it by 3 so that he actually picks up 3XP, then this event code will add 2XP to the already picked up 1XP to total 3XP.
     
  3. Offline

    MCCoding

    Musaddict
    Ah okay well what I might just do is disable xp orbs from dropping and when a player kills a bob etc at will just add the xp to their xp bar. Also how would I be able to make it so there is a level cap so you can't get over level 50?
     
  4. Offline

    Musaddict

    Call whatever the XP level up event is, and if the level is >50, cancel the event.

    Edit: alternatively, if you are manually going to be adding XP to the player, then just don't give any XP if the player is lvl 50 or higher.
     
Thread Status:
Not open for further replies.

Share This Page