Update XPCheque to use calculateTotalExperiencePoints and setExperienceLevelAndProgress to fix exp reset bug

This commit is contained in:
akastijn 2025-07-22 19:27:12 +02:00
parent 7625c57b8b
commit c66b30ff90

View File

@ -64,7 +64,7 @@ public class XPCheque extends SubCommand {
return true;
}
int totalExperience = player.getTotalExperience();
int totalExperience = player.calculateTotalExperiencePoints();
if (totalExperience < (xpValue * amount)) {
commandSender.sendRichMessage(Messages.XP_CHEQUE.NOT_ENOUGH_XP, Placeholder.parsed("xp", String.valueOf(totalExperience)));
return true;
@ -139,7 +139,7 @@ public class XPCheque extends SubCommand {
}
public void decreaseExperience(Player player, int xpToRemove) {
int totalExp = player.getTotalExperience();
int totalExp = player.calculateTotalExperiencePoints();
int newTotalExp = Math.max(totalExp - xpToRemove, 0);
int level = 0;
@ -153,7 +153,7 @@ public class XPCheque extends SubCommand {
float progress = (float) newTotalExp / getExpToNext(level);
player.setTotalExperience(totalExp - xpToRemove);
player.setExperienceLevelAndProgress(totalExp - xpToRemove);
player.setLevel(level);
player.setExp(progress);
}