diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensBlazeNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensBlazeNPC.java index 2bd59fd2c..cc31d0adf 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensBlazeNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensBlazeNPC.java @@ -59,7 +59,8 @@ public class CitizensBlazeNPC extends CitizensMobNPC { // this method is called by both the entities involved - cancelling // it will not stop the NPC from moving. super.collide(entity); - Util.callCollisionEvent(npc, entity); + if (npc != null) + Util.callCollisionEvent(npc, entity); } @Override @@ -68,8 +69,11 @@ public class CitizensBlazeNPC extends CitizensMobNPC { super.g(x, y, z); return; } - if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) { + if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) + super.g(x, y, z); return; + } Vector vector = new Vector(x, y, z); NPCPushEvent event = Util.callPushEvent(npc, vector); if (!event.isCancelled()) { diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensCaveSpiderNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensCaveSpiderNPC.java index 0d35e4121..7cc51830f 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensCaveSpiderNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensCaveSpiderNPC.java @@ -66,7 +66,8 @@ public class CitizensCaveSpiderNPC extends CitizensMobNPC { // this method is called by both the entities involved - cancelling // it will not stop the NPC from moving. super.collide(entity); - Util.callCollisionEvent(npc, entity); + if (npc != null) + Util.callCollisionEvent(npc, entity); } @Override @@ -75,8 +76,11 @@ public class CitizensCaveSpiderNPC extends CitizensMobNPC { super.g(x, y, z); return; } - if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) { + if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) + super.g(x, y, z); return; + } Vector vector = new Vector(x, y, z); NPCPushEvent event = Util.callPushEvent(npc, vector); if (!event.isCancelled()) { diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensChickenNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensChickenNPC.java index 2aba92fe8..622c6b7a6 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensChickenNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensChickenNPC.java @@ -51,7 +51,8 @@ public class CitizensChickenNPC extends CitizensMobNPC { // this method is called by both the entities involved - cancelling // it will not stop the NPC from moving. super.collide(entity); - Util.callCollisionEvent(npc, entity); + if (npc != null) + Util.callCollisionEvent(npc, entity); } @Override @@ -60,8 +61,11 @@ public class CitizensChickenNPC extends CitizensMobNPC { super.g(x, y, z); return; } - if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) { + if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) + super.g(x, y, z); return; + } Vector vector = new Vector(x, y, z); NPCPushEvent event = Util.callPushEvent(npc, vector); if (!event.isCancelled()) { diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensCowNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensCowNPC.java index 00a994e73..5820e8ddc 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensCowNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensCowNPC.java @@ -51,7 +51,8 @@ public class CitizensCowNPC extends CitizensMobNPC { // this method is called by both the entities involved - cancelling // it will not stop the NPC from moving. super.collide(entity); - Util.callCollisionEvent(npc, entity); + if (npc != null) + Util.callCollisionEvent(npc, entity); } @Override @@ -60,8 +61,11 @@ public class CitizensCowNPC extends CitizensMobNPC { super.g(x, y, z); return; } - if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) { + if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) + super.g(x, y, z); return; + } Vector vector = new Vector(x, y, z); NPCPushEvent event = Util.callPushEvent(npc, vector); if (!event.isCancelled()) { diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensCreeperNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensCreeperNPC.java index 6d45131b7..c36c80aa3 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensCreeperNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensCreeperNPC.java @@ -65,7 +65,8 @@ public class CitizensCreeperNPC extends CitizensMobNPC { // this method is called by both the entities involved - cancelling // it will not stop the NPC from moving. super.collide(entity); - Util.callCollisionEvent(npc, entity); + if (npc != null) + Util.callCollisionEvent(npc, entity); } @Override @@ -74,8 +75,11 @@ public class CitizensCreeperNPC extends CitizensMobNPC { super.g(x, y, z); return; } - if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) { + if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) + super.g(x, y, z); return; + } Vector vector = new Vector(x, y, z); NPCPushEvent event = Util.callPushEvent(npc, vector); if (!event.isCancelled()) { diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensEnderDragonNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensEnderDragonNPC.java index 015bd9e1d..2880927c5 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensEnderDragonNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensEnderDragonNPC.java @@ -53,7 +53,8 @@ public class CitizensEnderDragonNPC extends CitizensMobNPC { // this method is called by both the entities involved - cancelling // it will not stop the NPC from moving. super.collide(entity); - Util.callCollisionEvent(npc, entity); + if (npc != null) + Util.callCollisionEvent(npc, entity); } @Override @@ -70,8 +71,11 @@ public class CitizensEnderDragonNPC extends CitizensMobNPC { super.g(x, y, z); return; } - if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) { + if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) + super.g(x, y, z); return; + } Vector vector = new Vector(x, y, z); NPCPushEvent event = Util.callPushEvent(npc, vector); if (!event.isCancelled()) { diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensEndermanNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensEndermanNPC.java index c7eac9323..73449ea62 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensEndermanNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensEndermanNPC.java @@ -106,7 +106,8 @@ public class CitizensEndermanNPC extends CitizensMobNPC implements Equipable { // this method is called by both the entities involved - cancelling // it will not stop the NPC from moving. super.collide(entity); - Util.callCollisionEvent(npc, entity); + if (npc != null) + Util.callCollisionEvent(npc, entity); } @Override @@ -125,8 +126,11 @@ public class CitizensEndermanNPC extends CitizensMobNPC implements Equipable { super.g(x, y, z); return; } - if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) { + if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) + super.g(x, y, z); return; + } Vector vector = new Vector(x, y, z); NPCPushEvent event = Util.callPushEvent(npc, vector); if (!event.isCancelled()) { diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensGhastNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensGhastNPC.java index 03219744a..af547e68a 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensGhastNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensGhastNPC.java @@ -59,7 +59,8 @@ public class CitizensGhastNPC extends CitizensMobNPC { // this method is called by both the entities involved - cancelling // it will not stop the NPC from moving. super.collide(entity); - Util.callCollisionEvent(npc, entity); + if (npc != null) + Util.callCollisionEvent(npc, entity); } @Override @@ -68,8 +69,11 @@ public class CitizensGhastNPC extends CitizensMobNPC { super.g(x, y, z); return; } - if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) { + if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) + super.g(x, y, z); return; + } Vector vector = new Vector(x, y, z); NPCPushEvent event = Util.callPushEvent(npc, vector); if (!event.isCancelled()) { diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensGiantNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensGiantNPC.java index 267f8b77d..28572e90c 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensGiantNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensGiantNPC.java @@ -55,7 +55,8 @@ public class CitizensGiantNPC extends CitizensMobNPC { // this method is called by both the entities involved - cancelling // it will not stop the NPC from moving. super.collide(entity); - Util.callCollisionEvent(npc, entity); + if (npc != null) + Util.callCollisionEvent(npc, entity); } @Override @@ -64,8 +65,11 @@ public class CitizensGiantNPC extends CitizensMobNPC { super.g(x, y, z); return; } - if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) { + if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) + super.g(x, y, z); return; + } Vector vector = new Vector(x, y, z); NPCPushEvent event = Util.callPushEvent(npc, vector); if (!event.isCancelled()) { diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensIronGolemNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensIronGolemNPC.java index e382f4ccc..a380f7822 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensIronGolemNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensIronGolemNPC.java @@ -54,7 +54,8 @@ public class CitizensIronGolemNPC extends CitizensMobNPC { // this method is called by both the entities involved - cancelling // it will not stop the NPC from moving. super.collide(entity); - Util.callCollisionEvent(npc, entity); + if (npc != null) + Util.callCollisionEvent(npc, entity); } @Override @@ -63,8 +64,11 @@ public class CitizensIronGolemNPC extends CitizensMobNPC { super.g(x, y, z); return; } - if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) { + if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) + super.g(x, y, z); return; + } Vector vector = new Vector(x, y, z); NPCPushEvent event = Util.callPushEvent(npc, vector); if (!event.isCancelled()) { diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensMagmaCubeNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensMagmaCubeNPC.java index 1c1308ea2..c61ba6acb 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensMagmaCubeNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensMagmaCubeNPC.java @@ -69,7 +69,8 @@ public class CitizensMagmaCubeNPC extends CitizensMobNPC { // this method is called by both the entities involved - cancelling // it will not stop the NPC from moving. super.collide(entity); - Util.callCollisionEvent(npc, entity); + if (npc != null) + Util.callCollisionEvent(npc, entity); } @Override @@ -78,8 +79,11 @@ public class CitizensMagmaCubeNPC extends CitizensMobNPC { super.g(x, y, z); return; } - if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) { + if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) + super.g(x, y, z); return; + } Vector vector = new Vector(x, y, z); NPCPushEvent event = Util.callPushEvent(npc, vector); if (!event.isCancelled()) { diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensMushroomCowNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensMushroomCowNPC.java index 2d94086c0..c88a2fa32 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensMushroomCowNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensMushroomCowNPC.java @@ -51,7 +51,8 @@ public class CitizensMushroomCowNPC extends CitizensMobNPC { // this method is called by both the entities involved - cancelling // it will not stop the NPC from moving. super.collide(entity); - Util.callCollisionEvent(npc, entity); + if (npc != null) + Util.callCollisionEvent(npc, entity); } @Override @@ -60,8 +61,11 @@ public class CitizensMushroomCowNPC extends CitizensMobNPC { super.g(x, y, z); return; } - if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) { + if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) + super.g(x, y, z); return; + } Vector vector = new Vector(x, y, z); NPCPushEvent event = Util.callPushEvent(npc, vector); if (!event.isCancelled()) { diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensOcelotNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensOcelotNPC.java index ffce2349e..cdc4585bf 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensOcelotNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensOcelotNPC.java @@ -58,7 +58,8 @@ public class CitizensOcelotNPC extends CitizensMobNPC { // this method is called by both the entities involved - cancelling // it will not stop the NPC from moving. super.collide(entity); - Util.callCollisionEvent(npc, entity); + if (npc != null) + Util.callCollisionEvent(npc, entity); } @Override @@ -67,8 +68,11 @@ public class CitizensOcelotNPC extends CitizensMobNPC { super.g(x, y, z); return; } - if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) { + if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) + super.g(x, y, z); return; + } Vector vector = new Vector(x, y, z); NPCPushEvent event = Util.callPushEvent(npc, vector); if (!event.isCancelled()) { diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensPigNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensPigNPC.java index cf37ee116..653a0f7df 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensPigNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensPigNPC.java @@ -84,7 +84,8 @@ public class CitizensPigNPC extends CitizensMobNPC implements Equipable { // this method is called by both the entities involved - cancelling // it will not stop the NPC from moving. super.collide(entity); - Util.callCollisionEvent(npc, entity); + if (npc != null) + Util.callCollisionEvent(npc, entity); } @Override @@ -93,8 +94,11 @@ public class CitizensPigNPC extends CitizensMobNPC implements Equipable { super.g(x, y, z); return; } - if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) { + if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) + super.g(x, y, z); return; + } Vector vector = new Vector(x, y, z); NPCPushEvent event = Util.callPushEvent(npc, vector); if (!event.isCancelled()) { diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensPigZombieNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensPigZombieNPC.java index 852b1fc0a..ed2e40aad 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensPigZombieNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensPigZombieNPC.java @@ -68,7 +68,8 @@ public class CitizensPigZombieNPC extends CitizensMobNPC { // this method is called by both the entities involved - cancelling // it will not stop the NPC from moving. super.collide(entity); - Util.callCollisionEvent(npc, entity); + if (npc != null) + Util.callCollisionEvent(npc, entity); } @Override @@ -77,8 +78,11 @@ public class CitizensPigZombieNPC extends CitizensMobNPC { super.g(x, y, z); return; } - if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) { + if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) + super.g(x, y, z); return; + } Vector vector = new Vector(x, y, z); NPCPushEvent event = Util.callPushEvent(npc, vector); if (!event.isCancelled()) { diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensSheepNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensSheepNPC.java index fcf9d4f1a..67935b9e7 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensSheepNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensSheepNPC.java @@ -89,7 +89,8 @@ public class CitizensSheepNPC extends CitizensMobNPC implements Equipable { // this method is called by both the entities involved - cancelling // it will not stop the NPC from moving. super.collide(entity); - Util.callCollisionEvent(npc, entity); + if (npc != null) + Util.callCollisionEvent(npc, entity); } @Override @@ -98,8 +99,11 @@ public class CitizensSheepNPC extends CitizensMobNPC implements Equipable { super.g(x, y, z); return; } - if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) { + if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) + super.g(x, y, z); return; + } Vector vector = new Vector(x, y, z); NPCPushEvent event = Util.callPushEvent(npc, vector); if (!event.isCancelled()) { diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensSilverfishNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensSilverfishNPC.java index f0b3cff3d..11729b495 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensSilverfishNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensSilverfishNPC.java @@ -68,7 +68,8 @@ public class CitizensSilverfishNPC extends CitizensMobNPC { // this method is called by both the entities involved - cancelling // it will not stop the NPC from moving. super.collide(entity); - Util.callCollisionEvent(npc, entity); + if (npc != null) + Util.callCollisionEvent(npc, entity); } @Override @@ -77,8 +78,11 @@ public class CitizensSilverfishNPC extends CitizensMobNPC { super.g(x, y, z); return; } - if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) { + if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) + super.g(x, y, z); return; + } Vector vector = new Vector(x, y, z); NPCPushEvent event = Util.callPushEvent(npc, vector); if (!event.isCancelled()) { diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensSkeletonNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensSkeletonNPC.java index d11ae380f..1402ce5f0 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensSkeletonNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensSkeletonNPC.java @@ -58,7 +58,8 @@ public class CitizensSkeletonNPC extends CitizensMobNPC { // this method is called by both the entities involved - cancelling // it will not stop the NPC from moving. super.collide(entity); - Util.callCollisionEvent(npc, entity); + if (npc != null) + Util.callCollisionEvent(npc, entity); } @Override @@ -67,8 +68,11 @@ public class CitizensSkeletonNPC extends CitizensMobNPC { super.g(x, y, z); return; } - if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) { + if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) + super.g(x, y, z); return; + } Vector vector = new Vector(x, y, z); NPCPushEvent event = Util.callPushEvent(npc, vector); if (!event.isCancelled()) { diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensSlimeNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensSlimeNPC.java index b4309a5cf..63ccdb97c 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensSlimeNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensSlimeNPC.java @@ -69,7 +69,8 @@ public class CitizensSlimeNPC extends CitizensMobNPC { // this method is called by both the entities involved - cancelling // it will not stop the NPC from moving. super.collide(entity); - Util.callCollisionEvent(npc, entity); + if (npc != null) + Util.callCollisionEvent(npc, entity); } @Override @@ -78,8 +79,11 @@ public class CitizensSlimeNPC extends CitizensMobNPC { super.g(x, y, z); return; } - if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) { + if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) + super.g(x, y, z); return; + } Vector vector = new Vector(x, y, z); NPCPushEvent event = Util.callPushEvent(npc, vector); if (!event.isCancelled()) { diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensSnowmanNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensSnowmanNPC.java index 3b92dba97..0ce3c07b3 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensSnowmanNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensSnowmanNPC.java @@ -54,7 +54,8 @@ public class CitizensSnowmanNPC extends CitizensMobNPC { // this method is called by both the entities involved - cancelling // it will not stop the NPC from moving. super.collide(entity); - Util.callCollisionEvent(npc, entity); + if (npc != null) + Util.callCollisionEvent(npc, entity); } @Override @@ -63,8 +64,11 @@ public class CitizensSnowmanNPC extends CitizensMobNPC { super.g(x, y, z); return; } - if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) { + if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) + super.g(x, y, z); return; + } Vector vector = new Vector(x, y, z); NPCPushEvent event = Util.callPushEvent(npc, vector); if (!event.isCancelled()) { diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensSpiderNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensSpiderNPC.java index c907c5f3e..a4c878af6 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensSpiderNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensSpiderNPC.java @@ -67,7 +67,8 @@ public class CitizensSpiderNPC extends CitizensMobNPC { // this method is called by both the entities involved - cancelling // it will not stop the NPC from moving. super.collide(entity); - Util.callCollisionEvent(npc, entity); + if (npc != null) + Util.callCollisionEvent(npc, entity); } @Override @@ -76,8 +77,11 @@ public class CitizensSpiderNPC extends CitizensMobNPC { super.g(x, y, z); return; } - if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) { + if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) + super.g(x, y, z); return; + } Vector vector = new Vector(x, y, z); NPCPushEvent event = Util.callPushEvent(npc, vector); if (!event.isCancelled()) { diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensSquidNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensSquidNPC.java index 374ce1f8e..3154d154a 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensSquidNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensSquidNPC.java @@ -59,7 +59,8 @@ public class CitizensSquidNPC extends CitizensMobNPC { // this method is called by both the entities involved - cancelling // it will not stop the NPC from moving. super.collide(entity); - Util.callCollisionEvent(npc, entity); + if (npc != null) + Util.callCollisionEvent(npc, entity); } @Override @@ -68,8 +69,11 @@ public class CitizensSquidNPC extends CitizensMobNPC { super.g(x, y, z); return; } - if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) { + if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) + super.g(x, y, z); return; + } Vector vector = new Vector(x, y, z); NPCPushEvent event = Util.callPushEvent(npc, vector); if (!event.isCancelled()) { diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensVillagerNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensVillagerNPC.java index d10b9b5ab..7dea12d11 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensVillagerNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensVillagerNPC.java @@ -66,7 +66,8 @@ public class CitizensVillagerNPC extends CitizensMobNPC { // this method is called by both the entities involved - cancelling // it will not stop the NPC from moving. super.collide(entity); - Util.callCollisionEvent(npc, entity); + if (npc != null) + Util.callCollisionEvent(npc, entity); } @Override @@ -75,8 +76,11 @@ public class CitizensVillagerNPC extends CitizensMobNPC { super.g(x, y, z); return; } - if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) { + if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) + super.g(x, y, z); return; + } Vector vector = new Vector(x, y, z); NPCPushEvent event = Util.callPushEvent(npc, vector); if (!event.isCancelled()) { diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensWolfNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensWolfNPC.java index 456a22a75..a4625f649 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensWolfNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensWolfNPC.java @@ -58,7 +58,8 @@ public class CitizensWolfNPC extends CitizensMobNPC { // this method is called by both the entities involved - cancelling // it will not stop the NPC from moving. super.collide(entity); - Util.callCollisionEvent(npc, entity); + if (npc != null) + Util.callCollisionEvent(npc, entity); } @Override @@ -67,8 +68,11 @@ public class CitizensWolfNPC extends CitizensMobNPC { super.g(x, y, z); return; } - if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) { + if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) + super.g(x, y, z); return; + } Vector vector = new Vector(x, y, z); NPCPushEvent event = Util.callPushEvent(npc, vector); if (!event.isCancelled()) { diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensZombieNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensZombieNPC.java index e6ffc494a..802e30f25 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensZombieNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensZombieNPC.java @@ -58,7 +58,8 @@ public class CitizensZombieNPC extends CitizensMobNPC { // this method is called by both the entities involved - cancelling // it will not stop the NPC from moving. super.collide(entity); - Util.callCollisionEvent(npc, entity); + if (npc != null) + Util.callCollisionEvent(npc, entity); } @Override @@ -67,8 +68,11 @@ public class CitizensZombieNPC extends CitizensMobNPC { super.g(x, y, z); return; } - if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) { + if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) + super.g(x, y, z); return; + } Vector vector = new Vector(x, y, z); NPCPushEvent event = Util.callPushEvent(npc, vector); if (!event.isCancelled()) { diff --git a/src/main/java/net/citizensnpcs/npc/entity/EntityHumanNPC.java b/src/main/java/net/citizensnpcs/npc/entity/EntityHumanNPC.java index d14d8d2d6..56728d4e4 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/EntityHumanNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/EntityHumanNPC.java @@ -40,7 +40,8 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder { // this method is called by both the entities involved - cancelling // it will not stop the NPC from moving. super.collide(entity); - Util.callCollisionEvent(npc, entity); + if (npc != null) + Util.callCollisionEvent(npc, entity); } @Override @@ -49,8 +50,11 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder { super.g(x, y, z); return; } - if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) { + if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) + super.g(x, y, z); return; + } Vector vector = new Vector(x, y, z); NPCPushEvent event = Util.callPushEvent(npc, vector); if (!event.isCancelled()) {