mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-14 21:22:09 +00:00
New exp calculations.
This commit is contained in:
parent
ab82f550cf
commit
80f001fdb7
1 changed files with 17 additions and 8 deletions
|
@ -16,7 +16,7 @@ public class SetExpFix
|
||||||
player.setExp(0);
|
player.setExp(0);
|
||||||
player.setLevel(0);
|
player.setLevel(0);
|
||||||
player.setTotalExperience(0);
|
player.setTotalExperience(0);
|
||||||
|
|
||||||
//This following code is technically redundant now, as bukkit now calulcates levels more or less correctly
|
//This following code is technically redundant now, as bukkit now calulcates levels more or less correctly
|
||||||
//At larger numbers however... player.getExp(3000), only seems to give 2999, putting the below calculations off.
|
//At larger numbers however... player.getExp(3000), only seems to give 2999, putting the below calculations off.
|
||||||
int amount = exp;
|
int amount = exp;
|
||||||
|
@ -40,23 +40,32 @@ public class SetExpFix
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getExpToLevel(final Player player)
|
private static int getExpToLevel(final Player player)
|
||||||
{
|
{
|
||||||
return getExpToLevel(player.getLevel());
|
return getExpToLevel(player.getLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getExpToLevel(final int level)
|
private static int getExpToLevel(final int level)
|
||||||
{
|
{
|
||||||
return 7 + (level * 7 >> 1);
|
if (level >= 30)
|
||||||
|
{
|
||||||
|
return 62 + (level - 30) * 7;
|
||||||
|
}
|
||||||
|
if (level >= 15)
|
||||||
|
{
|
||||||
|
return 17 + (level - 15) * 3;
|
||||||
|
}
|
||||||
|
return 17;
|
||||||
}
|
}
|
||||||
|
|
||||||
//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 = (int)Math.round(getExpToLevel(player) * player.getExp());
|
int exp = (int)Math.round(getExpToLevel(player) * player.getExp());
|
||||||
int currentLevel = player.getLevel();
|
int currentLevel = player.getLevel();
|
||||||
|
|
||||||
while (currentLevel > 0) {
|
while (currentLevel > 0)
|
||||||
|
{
|
||||||
currentLevel--;
|
currentLevel--;
|
||||||
exp += getExpToLevel(currentLevel);
|
exp += getExpToLevel(currentLevel);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue