Apply patch "Fixed exp for 1.8" from Spigot-Essentials, fixes #3

This commit is contained in:
vemacs 2015-06-04 20:44:02 -06:00
parent 8e2ffe08f8
commit 3634cab1a5

View File

@ -36,14 +36,16 @@ public class SetExpFix {
return getExpAtLevel(player.getLevel()); return getExpAtLevel(player.getLevel());
} }
//new Exp Math from 1.8
public static int getExpAtLevel(final int level) { public static int getExpAtLevel(final int level) {
if (level > 29) { if (level <= 15) {
return 62 + (level - 30) * 7; return (2 * level) + 7;
} }
if (level > 15) { if ((level >= 16) && (level <= 30)) {
return 17 + (level - 15) * 3; return (5 * level) - 38;
} }
return 17; return (9 * level) - 158;
} }
public static int getExpToLevel(final int level) { public static int getExpToLevel(final int level) {
@ -63,7 +65,7 @@ public class SetExpFix {
//This method is required because the bukkit player.getTotalExperience() method, shows exp that has been 'spent'. //This method is required because the bukkit player.getTotalExperience() method, shows exp that has been 'spent'.
//Without this people would be able to use exp and then still sell it. //Without this people would be able to use exp and then still sell it.
public static int getTotalExperience(final Player player) { public static int getTotalExperience(final Player player) {
int exp = Math.round(getExpAtLevel(player) * player.getExp()); int exp = (int) Math.round(getExpAtLevel(player) * player.getExp());
int currentLevel = player.getLevel(); int currentLevel = player.getLevel();
while (currentLevel > 0) { while (currentLevel > 0) {
@ -77,8 +79,8 @@ public class SetExpFix {
} }
public static int getExpUntilNextLevel(final Player player) { public static int getExpUntilNextLevel(final Player player) {
int exp = Math.round(getExpAtLevel(player) * player.getExp()); int exp = (int) Math.round(getExpAtLevel(player) * player.getExp());
int nextLevel = player.getLevel(); int nextLevel = player.getLevel();
return getExpAtLevel(nextLevel) - exp; return getExpAtLevel(nextLevel) - exp;
} }
} }