From 30c3d0827358645e3b1a999b3a9de1b7f37dff08 Mon Sep 17 00:00:00 2001 From: Aria Date: Wed, 18 Sep 2019 16:40:35 +0200 Subject: [PATCH] NPC safechecks --- src/main/java/net/Indyuce/mmocore/listener/PlayerListener.java | 1 + .../mmocore/listener/event/PlayerAttackEventListener.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/Indyuce/mmocore/listener/PlayerListener.java b/src/main/java/net/Indyuce/mmocore/listener/PlayerListener.java index 9dde416c..40690760 100644 --- a/src/main/java/net/Indyuce/mmocore/listener/PlayerListener.java +++ b/src/main/java/net/Indyuce/mmocore/listener/PlayerListener.java @@ -56,6 +56,7 @@ public class PlayerListener implements Listener { */ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void d(EntityDamageByEntityEvent event) { + if(event.getEntity().hasMetadata("NPC")) return; if (event.getEntity() instanceof Player) PlayerData.get((Player) event.getEntity()).updateCombat(); diff --git a/src/main/java/net/Indyuce/mmocore/listener/event/PlayerAttackEventListener.java b/src/main/java/net/Indyuce/mmocore/listener/event/PlayerAttackEventListener.java index e08c4ace..a1f00c75 100644 --- a/src/main/java/net/Indyuce/mmocore/listener/event/PlayerAttackEventListener.java +++ b/src/main/java/net/Indyuce/mmocore/listener/event/PlayerAttackEventListener.java @@ -47,7 +47,7 @@ public class PlayerAttackEventListener implements Listener { * check damage systems from other MMOCore plugins + from MMOCore, and * register an attack damage for easier plugin calculations */ - if (damager instanceof Player) + if (damager instanceof Player && !damager.hasMetadata("NPC")) Bukkit.getPluginManager().callEvent(new PlayerAttackEvent(PlayerData.get((Player) damager), event, MMOCore.plugin.damage.findInfo(event.getEntity()).merge(info))); /*