mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-24 06:06:45 +01:00
3c5bd3cedd
Band aid for broken isValid() function. Fixes #1396
31 lines
986 B
Java
31 lines
986 B
Java
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) {
|
|
if (target.isValid()) {
|
|
this.target = target;
|
|
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()) {
|
|
target.setCustomNameVisible(oldNameVisible);
|
|
target.setCustomName(oldName);
|
|
target.removeMetadata(mcMMO.customNameKey, mcMMO.p);
|
|
target.removeMetadata(mcMMO.customVisibleKey, mcMMO.p);
|
|
}
|
|
}
|
|
}
|