|
@@ -6,23 +6,20 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|
|
|
|
|
public class MobHealthDisplayUpdaterTask extends BukkitRunnable {
|
|
|
private LivingEntity target;
|
|
|
- private String oldName;
|
|
|
- private boolean oldNameVisible;
|
|
|
|
|
|
public MobHealthDisplayUpdaterTask(LivingEntity target) {
|
|
|
- if (target.isValid()) {
|
|
|
- this.target = target;
|
|
|
- this.oldName = target.getMetadata(mcMMO.customNameKey).get(0).asString();
|
|
|
- this.oldNameVisible = target.getMetadata(mcMMO.customVisibleKey).get(0).asBoolean();
|
|
|
- }
|
|
|
+ this.target = target;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void run() {
|
|
|
- if (target != null && target.isValid()) {
|
|
|
- target.setCustomNameVisible(oldNameVisible);
|
|
|
- target.setCustomName(oldName);
|
|
|
+ if (target.hasMetadata(mcMMO.customNameKey)) {
|
|
|
+ target.setCustomName(target.getMetadata(mcMMO.customNameKey).get(0).asString());
|
|
|
target.removeMetadata(mcMMO.customNameKey, mcMMO.p);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (target.hasMetadata(mcMMO.customVisibleKey)) {
|
|
|
+ target.setCustomNameVisible(target.getMetadata(mcMMO.customVisibleKey).get(0).asBoolean());
|
|
|
target.removeMetadata(mcMMO.customVisibleKey, mcMMO.p);
|
|
|
}
|
|
|
}
|