Skip to content

Instantly share code, notes, and snippets.

@RoboMWM
Created August 19, 2017 21:55
Show Gist options
  • Select an option

  • Save RoboMWM/9fdaecb3c4dbf231368360b974b30eef to your computer and use it in GitHub Desktop.

Select an option

Save RoboMWM/9fdaecb3c4dbf231368360b974b30eef to your computer and use it in GitHub Desktop.
SetExpFix in EssentialsX

[14:47:55] +SupaHam: RoboMWM: oh i think the first one is to represent how much exp is required on one level. Whereas getExpToLevel returns all the exp required upto the specified level

[14:48:13] +SupaHam: so so getExpToLevel is a total, and getExpAtLevel is a single iteration in that total

@RoboMWM
Copy link
Copy Markdown
Author

RoboMWM commented Aug 19, 2017

https://github.com/drtshock/Essentials/blob/2.x/Essentials/src/com/earth2me/essentials/craftbukkit/SetExpFix.java#L51

    //new Exp Math from 1.8
    public static int getExpAtLevel(final int level) {
        if (level <= 15) {
            return (2 * level) + 7;
        }
        if ((level >= 16) && (level <= 30)) {
            return (5 * level) - 38;
        }
        return (9 * level) - 158;

    }

    public static int getExpToLevel(final int level) {
        int currentLevel = 0;
        int exp = 0;

        while (currentLevel < level) {
            exp += getExpAtLevel(currentLevel);
            currentLevel++;
        }
        if (exp < 0) {
            exp = Integer.MAX_VALUE;
        }
        return exp;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment