diff --git a/Changelog.txt b/Changelog.txt index 5d7139249..3269027c9 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,5 +1,6 @@ Version 2.1.112 Correct locale usage for enum access, now enforces using the english locale to prevent issues with oddball locales for configs/commands + Don't cache names in mob health updater task, also; Don't schedule if the entity is already dead Version 2.1.111 mcMMO is compatible with the following versions of MC: 1.15 / 1.14.4 / 1.14.3 / 1.14.2 / 1.14.1 / 1.14 / 1.13.2 diff --git a/src/main/java/com/gmail/nossr50/runnables/MobHealthDisplayUpdaterTask.java b/src/main/java/com/gmail/nossr50/runnables/MobHealthDisplayUpdaterTask.java index a81cc21ed..111ed9482 100644 --- a/src/main/java/com/gmail/nossr50/runnables/MobHealthDisplayUpdaterTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/MobHealthDisplayUpdaterTask.java @@ -6,23 +6,20 @@ import org.bukkit.scheduler.BukkitRunnable; 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(); - } + this.target = target; } @Override public void run() { - if (target != null && target.isValid()) { - target.setCustomNameVisible(oldNameVisible); - target.setCustomName(oldName); + if (target.hasMetadata(mcMMO.customNameKey)) { + target.setCustomName(target.getMetadata(mcMMO.customNameKey).get(0).asString()); target.removeMetadata(mcMMO.customNameKey, mcMMO.p); + } + + if (target.hasMetadata(mcMMO.customVisibleKey)) { + target.setCustomNameVisible(target.getMetadata(mcMMO.customVisibleKey).get(0).asBoolean()); target.removeMetadata(mcMMO.customVisibleKey, mcMMO.p); } } diff --git a/src/main/java/com/gmail/nossr50/util/MobHealthbarUtils.java b/src/main/java/com/gmail/nossr50/util/MobHealthbarUtils.java index 9c40f8aa6..815ab39e3 100644 --- a/src/main/java/com/gmail/nossr50/util/MobHealthbarUtils.java +++ b/src/main/java/com/gmail/nossr50/util/MobHealthbarUtils.java @@ -60,6 +60,11 @@ public final class MobHealthbarUtils { return; } + // Don't mangle invalid entities, they're not going to be rendered anyways + if (!target.isValid()) { + return; + } + boolean oldNameVisible = target.isCustomNameVisible(); String newName = createHealthDisplay(Config.getInstance().getMobHealthbarDefault(), target, damage);