From 3f7b17961ff4c49ba3e90ba0ceb8a7cdcb3110ae Mon Sep 17 00:00:00 2001 From: T00thpick1 Date: Thu, 6 Jun 2013 23:46:33 -0400 Subject: [PATCH] Reset mob healthbars on death to avoid conflicting with loot plugins --- .../nossr50/listeners/EntityListener.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index fa44a1857..27fb1f0d9 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -323,6 +323,30 @@ public class EntityListener implements Listener { } } + /** + * Monitor EntityDeath events. + * + * @param event The event to watch + */ + @EventHandler(priority = EventPriority.LOWEST) + public void onEntityDeathLowest(EntityDeathEvent event) { + LivingEntity entity = event.getEntity(); + + if (Misc.isNPCEntity(entity)) { + return; + } + + if (entity.hasMetadata(mcMMO.customNameKey)) { + entity.setCustomName(entity.getMetadata(mcMMO.customNameKey).get(0).asString()); + entity.removeMetadata(mcMMO.customNameKey, mcMMO.p); + } + + if (entity.hasMetadata(mcMMO.customVisibleKey)) { + entity.setCustomNameVisible(entity.getMetadata(mcMMO.customVisibleKey).get(0).asBoolean()); + entity.removeMetadata(mcMMO.customVisibleKey, mcMMO.p); + } + } + /** * Monitor EntityDeath events. *