Remove metadata, validation checks.

This commit is contained in:
GJ 2013-04-08 00:24:38 -04:00
parent 7d6eb65776
commit b82c3f41d3
2 changed files with 12 additions and 7 deletions

View File

@ -12,13 +12,20 @@ public class MobHealthDisplayUpdaterTask extends BukkitRunnable {
public MobHealthDisplayUpdaterTask(LivingEntity target) { public MobHealthDisplayUpdaterTask(LivingEntity target) {
this.target = target; this.target = target;
if (target.isValid()) {
this.oldName = target.getMetadata(mcMMO.customNameKey).get(0).asString(); this.oldName = target.getMetadata(mcMMO.customNameKey).get(0).asString();
this.oldNameVisible = target.getMetadata(mcMMO.customVisibleKey).get(0).asBoolean(); this.oldNameVisible = target.getMetadata(mcMMO.customVisibleKey).get(0).asBoolean();
} }
}
@Override @Override
public void run() { public void run() {
if (target.isValid()) {
target.setCustomNameVisible(oldNameVisible); target.setCustomNameVisible(oldNameVisible);
target.setCustomName(oldName); target.setCustomName(oldName);
target.removeMetadata(mcMMO.customNameKey, mcMMO.p);
target.removeMetadata(mcMMO.customVisibleKey, mcMMO.p);
}
} }
} }

View File

@ -313,13 +313,11 @@ public final class CombatUtils {
target.setMetadata(mcMMO.customVisibleKey, new FixedMetadataValue(mcMMO.p, oldNameVisible)); target.setMetadata(mcMMO.customVisibleKey, new FixedMetadataValue(mcMMO.p, oldNameVisible));
} }
if (target.isValid()) {
new MobHealthDisplayUpdaterTask(target).runTaskLater(mcMMO.p, displayTime * 20); // Clear health display after 3 seconds new MobHealthDisplayUpdaterTask(target).runTaskLater(mcMMO.p, displayTime * 20); // Clear health display after 3 seconds
} }
} }
} }
} }
}
/** /**
* Attempt to damage target for value dmg with reason CUSTOM * Attempt to damage target for value dmg with reason CUSTOM