mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-12-01 01:23:25 +01:00
Check if attacked mob is an NPC closes #103
This commit is contained in:
parent
0eebaacc75
commit
8a9f3f03fb
@ -1,6 +1,7 @@
|
|||||||
package net.Indyuce.mmocore.listener;
|
package net.Indyuce.mmocore.listener;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -47,7 +48,10 @@ public class PartyListener implements Listener {
|
|||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||||
public void b(PlayerAttackEvent event) {
|
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());
|
PlayerData targetData = PlayerData.get((Player) event.getEntity());
|
||||||
if (targetData.hasParty() && targetData.getParty().getMembers().has(event.getData().getMMOCore()))
|
if (targetData.hasParty() && targetData.getParty().getMembers().has(event.getData().getMMOCore()))
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
Loading…
Reference in New Issue
Block a user