Hello, i had a question is it possible to set the exp you need to level up? nothing like Code: @EventHandler public void onPlayerExpChange(PlayerExpChangeEvent event) { int exp = event.getAmount(); //some code here event.setAmount(exp); } I really mean set exp to level up Sincerely Eistee² sorry for my bad english
Well, I'm not sure if you'll want to use PlayerExpChangeEvent because it'll level them up everytime they pick up an exp orb. But if you really wanted to use that event, something like this: Code:java @EventHandler public void onPlayerExpChange(PlayerExpChangeEvent e){ Player player = e.getPlayer(); player.setLevel(player.getLevel()+1); }
It only was an example I make it configurable how much exp you need for my plugin (minebuilder) because I had a request if I could add something like this and my question is it if i could it some thing like player.expToLevelUp = 20 ore something like that
Then I think something like this would work: Code:java int exp = (int)player.getExp(); player.setExp(exp+getConfig().getInt("Something"));
but this would only set exp or? Not the amount of exp you need to level up? But thanks for helping me
I'm actually now confused on what you're trying to do now. Do you want them to just level up, or did you actually want to find how much exp they need to level up?
Set how much they need to lvl up You need from lvl 1-16 = 17 exp 16-17 = 20 and so on... and i want to change this so you need for lvl 1 = 20 exp
I think I get what you're saying. So you want it to set custom exp levels. Code:java Player player = e.getPlayer(); if(player.getExp() == getConfig().getInt("Level1")){ player.setExp(0); player.setLevel(1); } if(player.getExp() == getConfig().getInt("Level2")){ player.setExp(0); player.setLevel(2); } if(player.getExp() == getConfig().getInt("Level3")){ player.setExp(0); player.setLevel(3); } It would be something like that. But I'm pretty sure there's a better way.