Skip to content

Commit

Permalink
Fix Xp Convert giving extremely high experience values
Browse files Browse the repository at this point in the history
  • Loading branch information
Archy-X committed Jul 21, 2024
1 parent 434cd8b commit a197e77
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,16 @@ public void xpConvert(XpGainEvent event) {
User user = BukkitUser.getUser(event.getUser());

if (!(event.getAmount() > 0)) return;

double totalXp = user.getAbilityData(ability).getDouble("xp") + event.getAmount();

double value = getValue(ability, user);
double prevData = Math.min(user.getAbilityData(ability).getDouble("xp"), value);
double eventAmount = event.getAmount();
double totalXp = prevData + eventAmount;
if (value > 0) {
int added = (int) (totalXp / value);
double remainder = totalXp - added * value;
player.giveExp(Math.max(added, 0));
user.getAbilityData(ability).setData("xp", remainder);
user.getAbilityData(ability).setData("xp", Math.min(remainder, value));
}
}

Expand Down

0 comments on commit a197e77

Please sign in to comment.