mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-12 12:23:59 +00:00
Comments to SetExpFix.
This commit is contained in:
parent
87cd693020
commit
e4ce814c2f
1 changed files with 7 additions and 0 deletions
|
@ -5,6 +5,8 @@ import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class SetExpFix
|
public class SetExpFix
|
||||||
{
|
{
|
||||||
|
//This method is used to update both the recorded total experience and displayed total experience.
|
||||||
|
//We reset both types to prevent issues.
|
||||||
public static void setTotalExperience(final Player player, final int exp)
|
public static void setTotalExperience(final Player player, final int exp)
|
||||||
{
|
{
|
||||||
if (exp < 0)
|
if (exp < 0)
|
||||||
|
@ -14,6 +16,9 @@ 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
|
||||||
|
//At larger numbers however... player.getExp(3000), only seems to give 2999, putting the below calculations off.
|
||||||
int amount = exp;
|
int amount = exp;
|
||||||
while (amount > 0)
|
while (amount > 0)
|
||||||
{
|
{
|
||||||
|
@ -44,6 +49,8 @@ public class SetExpFix
|
||||||
return 7 + (level * 7 >> 1);
|
return 7 + (level * 7 >> 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//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.
|
||||||
public static int getTotalExperience(final Player player)
|
public static int getTotalExperience(final Player player)
|
||||||
{
|
{
|
||||||
int exp = (int) (getExpToLevel(player) * player.getExp());
|
int exp = (int) (getExpToLevel(player) * player.getExp());
|
||||||
|
|
Loading…
Reference in a new issue