Update XPCheque to use calculateTotalExperiencePoints and setExperienceLevelAndProgress to fix exp reset bug
This commit is contained in:
parent
7625c57b8b
commit
c66b30ff90
|
|
@ -64,7 +64,7 @@ public class XPCheque extends SubCommand {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int totalExperience = player.getTotalExperience();
|
int totalExperience = player.calculateTotalExperiencePoints();
|
||||||
if (totalExperience < (xpValue * amount)) {
|
if (totalExperience < (xpValue * amount)) {
|
||||||
commandSender.sendRichMessage(Messages.XP_CHEQUE.NOT_ENOUGH_XP, Placeholder.parsed("xp", String.valueOf(totalExperience)));
|
commandSender.sendRichMessage(Messages.XP_CHEQUE.NOT_ENOUGH_XP, Placeholder.parsed("xp", String.valueOf(totalExperience)));
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -139,7 +139,7 @@ public class XPCheque extends SubCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void decreaseExperience(Player player, int xpToRemove) {
|
public void decreaseExperience(Player player, int xpToRemove) {
|
||||||
int totalExp = player.getTotalExperience();
|
int totalExp = player.calculateTotalExperiencePoints();
|
||||||
int newTotalExp = Math.max(totalExp - xpToRemove, 0);
|
int newTotalExp = Math.max(totalExp - xpToRemove, 0);
|
||||||
|
|
||||||
int level = 0;
|
int level = 0;
|
||||||
|
|
@ -153,7 +153,7 @@ public class XPCheque extends SubCommand {
|
||||||
|
|
||||||
float progress = (float) newTotalExp / getExpToNext(level);
|
float progress = (float) newTotalExp / getExpToNext(level);
|
||||||
|
|
||||||
player.setTotalExperience(totalExp - xpToRemove);
|
player.setExperienceLevelAndProgress(totalExp - xpToRemove);
|
||||||
player.setLevel(level);
|
player.setLevel(level);
|
||||||
player.setExp(progress);
|
player.setExp(progress);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user