From b82c3f41d3e68a2759733cb3801661eb9f0663e2 Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 8 Apr 2013 00:24:38 -0400 Subject: [PATCH] Remove metadata, validation checks. --- .../runnables/MobHealthDisplayUpdaterTask.java | 15 +++++++++++---- .../gmail/nossr50/util/skills/CombatUtils.java | 4 +--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/runnables/MobHealthDisplayUpdaterTask.java b/src/main/java/com/gmail/nossr50/runnables/MobHealthDisplayUpdaterTask.java index f5ae2444b..eaef6ea36 100644 --- a/src/main/java/com/gmail/nossr50/runnables/MobHealthDisplayUpdaterTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/MobHealthDisplayUpdaterTask.java @@ -12,13 +12,20 @@ public class MobHealthDisplayUpdaterTask extends BukkitRunnable { public MobHealthDisplayUpdaterTask(LivingEntity target) { this.target = target; - this.oldName = target.getMetadata(mcMMO.customNameKey).get(0).asString(); - this.oldNameVisible = target.getMetadata(mcMMO.customVisibleKey).get(0).asBoolean(); + + if (target.isValid()) { + this.oldName = target.getMetadata(mcMMO.customNameKey).get(0).asString(); + this.oldNameVisible = target.getMetadata(mcMMO.customVisibleKey).get(0).asBoolean(); + } } @Override public void run() { - target.setCustomNameVisible(oldNameVisible); - target.setCustomName(oldName); + if (target.isValid()) { + target.setCustomNameVisible(oldNameVisible); + target.setCustomName(oldName); + target.removeMetadata(mcMMO.customNameKey, mcMMO.p); + target.removeMetadata(mcMMO.customVisibleKey, mcMMO.p); + } } } diff --git a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java index 63c619002..8cad04087 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -313,9 +313,7 @@ public final class CombatUtils { 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 } } }