Browse Source

Clear mob health display if it gets stuck. Fixes #933

GJ 12 years ago
parent
commit
f3c6346b95
1 changed files with 7 additions and 1 deletions
  1. 7 1
      src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java

+ 7 - 1
src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java

@@ -308,10 +308,16 @@ public final class CombatUtils {
                         oldName = "";
                     }
 
-                    if (!ChatColor.stripColor(oldName).equalsIgnoreCase(ChatColor.stripColor(newName))) {
+                    boolean updateName = !ChatColor.stripColor(oldName).equalsIgnoreCase(ChatColor.stripColor(newName));
+
+                    if (updateName) {
                         target.setMetadata(mcMMO.customNameKey, new FixedMetadataValue(mcMMO.p, oldName));
                         target.setMetadata(mcMMO.customVisibleKey, new FixedMetadataValue(mcMMO.p, oldNameVisible));
                     }
+                    else if (!target.hasMetadata(mcMMO.customNameKey)) {
+                        target.setMetadata(mcMMO.customNameKey, new FixedMetadataValue(mcMMO.p, ""));
+                        target.setMetadata(mcMMO.customVisibleKey, new FixedMetadataValue(mcMMO.p, false));
+                    }
 
                     new MobHealthDisplayUpdaterTask(target).runTaskLater(mcMMO.p, displayTime * 20); // Clear health display after 3 seconds
                 }