From 8a9f3f03fb7e0e3d5ad4d80cdda238707f403b57 Mon Sep 17 00:00:00 2001 From: HexedHero <6012891+HexedHero@users.noreply.github.com> Date: Sat, 12 Sep 2020 01:09:39 +0100 Subject: [PATCH] Check if attacked mob is an NPC closes #103 --- .../java/net/Indyuce/mmocore/listener/PartyListener.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/Indyuce/mmocore/listener/PartyListener.java b/src/main/java/net/Indyuce/mmocore/listener/PartyListener.java index d3f379c5..057353f6 100644 --- a/src/main/java/net/Indyuce/mmocore/listener/PartyListener.java +++ b/src/main/java/net/Indyuce/mmocore/listener/PartyListener.java @@ -1,6 +1,7 @@ package net.Indyuce.mmocore.listener; import org.bukkit.Bukkit; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -47,7 +48,10 @@ public class PartyListener implements Listener { */ @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void b(PlayerAttackEvent event) { - if (event.getEntity() instanceof Player) { + LivingEntity entity = event.getEntity(); + if (entity instanceof Player) { + if (entity.hasMetadata("NPC")) + return; PlayerData targetData = PlayerData.get((Player) event.getEntity()); if (targetData.hasParty() && targetData.getParty().getMembers().has(event.getData().getMMOCore())) event.setCancelled(true);