Include total experience in SetExperience step.
It turns out that experience in Minecraft is split out on a couple of different variables, and they are only loosely coupled. Total experience, level, and level progress are three completely different variables that can be manipulated individually. This means that while 10 experience points from level 0 should bring you up to level 1 with a third of the experience bar full (level 0 to 1 takes 7 points, level 1 to 2 takes 9 points), simply setting the total points value to 10 won't automatically level you up. Using the Player#giveExp(int) method will, however, work this way.
This commit is contained in:
@@ -3,6 +3,7 @@ package com.garbagemule.MobArena.steps;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
class SetExperience extends PlayerStep {
|
||||
private int total;
|
||||
private int level;
|
||||
private float exp;
|
||||
|
||||
@@ -12,15 +13,18 @@ class SetExperience extends PlayerStep {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
total = player.getTotalExperience();
|
||||
level = player.getLevel();
|
||||
exp = player.getExp();
|
||||
|
||||
player.setExp(0);
|
||||
player.setLevel(0);
|
||||
player.setTotalExperience(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
player.setTotalExperience(total);
|
||||
player.setLevel(level);
|
||||
player.setExp(exp);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user