How to get progress to next level?

Discussion in 'Spigot Plugin Development' started by Snowmite, Apr 15, 2017.

  1. Alright, I haven't attempted this yet, but how would I get the progress to next level? I will have a custom player class that stores the current level, current xp, required xp for next level, and the next level. How would I make get the progress to the next level then display it?
     
  2. If you are not talking about the default leveling and experience points, it's really easy to check that
    What i do is giving exp when someone is mining or killing and when it goes to the max amount of exp for example exp 1000, when it goes to 1000 i set it to 0 and i get his level and add 1 more by level + 1, this is just a pseudocode but it's really easy if you think about it. You add with the same way levels and experience points.
     
  3. This class uses the formula that Mojang uses to calculate experience and it has some functions which can check how much xp is left until the next level without adding experience until it changes the level
    0-15: 17*level;
    16-30: 1.5*level^2 - 29.5*level+360
    30+: 3.5 * level^2 - 151.5 * level + 2220
     
    • Informative Informative x 2
  4. Okay so he was talking about minecraft default exp and leveling? because i was talking about custom leveling with experience. Because he said like "I will have a custom player class that stores the current level, current xp, required xp for next level, and the next level".
    so this is what it hought. And yes i did something basically same with my leveling.
    0-25 1000 EXP
    25-50 2000 EXP
    50-75 3000 EXP
    and 75-100 4.000 EXP
    in each level. Well it's not hard creating a leveling system.
     
  5. I suppose you could just take the same class and change the formulas to your own
     
  6. I just implemented something along the lines.

    - First -> you need your lvl to exp formula, I use Desmos, it's an online math function calculator that draws a graw for your grow curve but you can use any graphic calculator or program

    - Second -> you make a method or class that can apply said formula when passed a level

    - Third -> Get the experience needed for level and for level+1 and then substract the current experience and there you have what's remaining for next level

    - Bonus -> if you want to make that to percent you do exp*100 / exp for next level
     
  7. Yeah you could! Well i don't think this can be a hard thing i mean this took me 2 days to make everything about leveling and experience points. Its not something that it could take you a week.
     
  8. I was talking about a custom leveling system not the default xp.
     
  9. Then i just told what u can do