mcMMO/src/main/java/com/gmail/nossr50/runnables/MobHealthDisplayUpdaterTask.java

31 lines
986 B
Java
Raw Normal View History

package com.gmail.nossr50.runnables;
import org.bukkit.entity.LivingEntity;
import org.bukkit.scheduler.BukkitRunnable;
import com.gmail.nossr50.mcMMO;
public class MobHealthDisplayUpdaterTask extends BukkitRunnable {
private LivingEntity target;
private String oldName;
private boolean oldNameVisible;
public MobHealthDisplayUpdaterTask(LivingEntity target) {
2013-04-08 06:24:38 +02:00
if (target.isValid()) {
2013-04-08 06:26:12 +02:00
this.target = target;
2013-04-08 06:24:38 +02:00
this.oldName = target.getMetadata(mcMMO.customNameKey).get(0).asString();
this.oldNameVisible = target.getMetadata(mcMMO.customVisibleKey).get(0).asBoolean();
}
}
@Override
public void run() {
if (target != null && target.isValid()) {
2013-04-08 06:24:38 +02:00
target.setCustomNameVisible(oldNameVisible);
target.setCustomName(oldName);
target.removeMetadata(mcMMO.customNameKey, mcMMO.p);
target.removeMetadata(mcMMO.customVisibleKey, mcMMO.p);
}
}
}