diff --git a/src/main/java/net/citizensnpcs/Settings.java b/src/main/java/net/citizensnpcs/Settings.java index 3c459e2d2..5c75b0ae9 100644 --- a/src/main/java/net/citizensnpcs/Settings.java +++ b/src/main/java/net/citizensnpcs/Settings.java @@ -88,15 +88,18 @@ public class Settings { } public double asDouble() { - return (Double) value; + return ((Number) value).doubleValue(); } public float asFloat() { - return (Float) value; + return ((Number) value).floatValue(); } public int asInt() { - return Integer.parseInt(value.toString()); + if (value instanceof String) { + return Integer.parseInt(value.toString()); + } + return ((Number) value).intValue(); } @SuppressWarnings("unchecked") @@ -108,7 +111,7 @@ public class Settings { } public long asLong() { - return (Long) value; + return ((Number) value).longValue(); } public String asString() { diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensBlazeNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensBlazeNPC.java index 780ab46f4..d3f48b417 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensBlazeNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensBlazeNPC.java @@ -1,6 +1,6 @@ package net.citizensnpcs.npc.entity; -import net.citizensnpcs.api.event.NPCCollisionEvent; +import net.citizensnpcs.api.event.NPCPushEvent; import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.npc.CitizensMobNPC; import net.citizensnpcs.npc.CitizensNPC; @@ -46,13 +46,21 @@ public class CitizensBlazeNPC extends CitizensMobNPC { super.b_(x, y, z); return; } - if (NPCCollisionEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) return; - NPCCollisionEvent event = Util.callCollisionEvent(npc, new Vector(x, y, z)); + NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z)); if (!event.isCancelled()) super.b_(x, y, z); // when another entity collides, b_ is called to push the NPC - // so we prevent b_ from doing anything. + // so we prevent b_ from doing anything if the event is cancelled. + } + + @Override + public void collide(net.minecraft.server.Entity entity) { + // 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); } @Override diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensCaveSpiderNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensCaveSpiderNPC.java index 047e018a2..ffe47bc69 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensCaveSpiderNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensCaveSpiderNPC.java @@ -1,6 +1,6 @@ package net.citizensnpcs.npc.entity; -import net.citizensnpcs.api.event.NPCCollisionEvent; +import net.citizensnpcs.api.event.NPCPushEvent; import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.npc.CitizensMobNPC; import net.citizensnpcs.npc.CitizensNPC; @@ -42,13 +42,21 @@ public class CitizensCaveSpiderNPC extends CitizensMobNPC { super.b_(x, y, z); return; } - if (NPCCollisionEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) return; - NPCCollisionEvent event = Util.callCollisionEvent(npc, new Vector(x, y, z)); + NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z)); if (!event.isCancelled()) super.b_(x, y, z); // when another entity collides, b_ is called to push the NPC - // so we prevent b_ from doing anything. + // so we prevent b_ from doing anything if the event is cancelled. + } + + @Override + public void collide(net.minecraft.server.Entity entity) { + // 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); } @Override diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensChickenNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensChickenNPC.java index 4f97e7c0e..b1deee1ef 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensChickenNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensChickenNPC.java @@ -1,6 +1,6 @@ package net.citizensnpcs.npc.entity; -import net.citizensnpcs.api.event.NPCCollisionEvent; +import net.citizensnpcs.api.event.NPCPushEvent; import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.npc.CitizensMobNPC; import net.citizensnpcs.npc.CitizensNPC; @@ -46,13 +46,21 @@ public class CitizensChickenNPC extends CitizensMobNPC { super.b_(x, y, z); return; } - if (NPCCollisionEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) return; - NPCCollisionEvent event = Util.callCollisionEvent(npc, new Vector(x, y, z)); + NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z)); if (!event.isCancelled()) super.b_(x, y, z); // when another entity collides, b_ is called to push the NPC - // so we prevent b_ from doing anything. + // so we prevent b_ from doing anything if the event is cancelled. + } + + @Override + public void collide(net.minecraft.server.Entity entity) { + // 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); } @Override diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensCowNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensCowNPC.java index 7d9740645..513026ea6 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensCowNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensCowNPC.java @@ -1,6 +1,6 @@ package net.citizensnpcs.npc.entity; -import net.citizensnpcs.api.event.NPCCollisionEvent; +import net.citizensnpcs.api.event.NPCPushEvent; import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.npc.CitizensMobNPC; import net.citizensnpcs.npc.CitizensNPC; @@ -46,13 +46,21 @@ public class CitizensCowNPC extends CitizensMobNPC { super.b_(x, y, z); return; } - if (NPCCollisionEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) return; - NPCCollisionEvent event = Util.callCollisionEvent(npc, new Vector(x, y, z)); + NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z)); if (!event.isCancelled()) super.b_(x, y, z); // when another entity collides, b_ is called to push the NPC - // so we prevent b_ from doing anything. + // so we prevent b_ from doing anything if the event is cancelled. + } + + @Override + public void collide(net.minecraft.server.Entity entity) { + // 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); } @Override diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensCreeperNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensCreeperNPC.java index 98c55342f..a520a2fd9 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensCreeperNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensCreeperNPC.java @@ -1,6 +1,6 @@ package net.citizensnpcs.npc.entity; -import net.citizensnpcs.api.event.NPCCollisionEvent; +import net.citizensnpcs.api.event.NPCPushEvent; import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.npc.CitizensMobNPC; import net.citizensnpcs.npc.CitizensNPC; @@ -53,13 +53,21 @@ public class CitizensCreeperNPC extends CitizensMobNPC { super.b_(x, y, z); return; } - if (NPCCollisionEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) return; - NPCCollisionEvent event = Util.callCollisionEvent(npc, new Vector(x, y, z)); + NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z)); if (!event.isCancelled()) super.b_(x, y, z); // when another entity collides, b_ is called to push the NPC - // so we prevent b_ from doing anything. + // so we prevent b_ from doing anything if the event is cancelled. + } + + @Override + public void collide(net.minecraft.server.Entity entity) { + // 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); } @Override diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensEnderDragonNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensEnderDragonNPC.java index 56a328744..ac13ff481 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensEnderDragonNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensEnderDragonNPC.java @@ -1,6 +1,6 @@ package net.citizensnpcs.npc.entity; -import net.citizensnpcs.api.event.NPCCollisionEvent; +import net.citizensnpcs.api.event.NPCPushEvent; import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.npc.CitizensMobNPC; import net.citizensnpcs.npc.CitizensNPC; @@ -42,13 +42,21 @@ public class CitizensEnderDragonNPC extends CitizensMobNPC { super.b_(x, y, z); return; } - if (NPCCollisionEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) return; - NPCCollisionEvent event = Util.callCollisionEvent(npc, new Vector(x, y, z)); + NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z)); if (!event.isCancelled()) super.b_(x, y, z); // when another entity collides, b_ is called to push the NPC - // so we prevent b_ from doing anything. + // so we prevent b_ from doing anything if the event is cancelled. + } + + @Override + public void collide(net.minecraft.server.Entity entity) { + // 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); } @Override diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensEndermanNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensEndermanNPC.java index 9125fbc4b..4aac0bbcd 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensEndermanNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensEndermanNPC.java @@ -1,6 +1,6 @@ package net.citizensnpcs.npc.entity; -import net.citizensnpcs.api.event.NPCCollisionEvent; +import net.citizensnpcs.api.event.NPCPushEvent; import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.api.trait.trait.Equipment; import net.citizensnpcs.editor.Equipable; @@ -84,13 +84,21 @@ public class CitizensEndermanNPC extends CitizensMobNPC implements Equipable { super.b_(x, y, z); return; } - if (NPCCollisionEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) return; - NPCCollisionEvent event = Util.callCollisionEvent(npc, new Vector(x, y, z)); + NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z)); if (!event.isCancelled()) super.b_(x, y, z); // when another entity collides, b_ is called to push the NPC - // so we prevent b_ from doing anything. + // so we prevent b_ from doing anything if the event is cancelled. + } + + @Override + public void collide(net.minecraft.server.Entity entity) { + // 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); } @Override diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensGhastNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensGhastNPC.java index 47411b820..efffe5130 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensGhastNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensGhastNPC.java @@ -1,6 +1,6 @@ package net.citizensnpcs.npc.entity; -import net.citizensnpcs.api.event.NPCCollisionEvent; +import net.citizensnpcs.api.event.NPCPushEvent; import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.npc.CitizensMobNPC; import net.citizensnpcs.npc.CitizensNPC; @@ -46,13 +46,21 @@ public class CitizensGhastNPC extends CitizensMobNPC { super.b_(x, y, z); return; } - if (NPCCollisionEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) return; - NPCCollisionEvent event = Util.callCollisionEvent(npc, new Vector(x, y, z)); + NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z)); if (!event.isCancelled()) super.b_(x, y, z); // when another entity collides, b_ is called to push the NPC - // so we prevent b_ from doing anything. + // so we prevent b_ from doing anything if the event is cancelled. + } + + @Override + public void collide(net.minecraft.server.Entity entity) { + // 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); } @Override diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensGiantNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensGiantNPC.java index 63b6cb53b..91238bb64 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensGiantNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensGiantNPC.java @@ -1,6 +1,6 @@ package net.citizensnpcs.npc.entity; -import net.citizensnpcs.api.event.NPCCollisionEvent; +import net.citizensnpcs.api.event.NPCPushEvent; import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.npc.CitizensMobNPC; import net.citizensnpcs.npc.CitizensNPC; @@ -42,13 +42,21 @@ public class CitizensGiantNPC extends CitizensMobNPC { super.b_(x, y, z); return; } - if (NPCCollisionEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) return; - NPCCollisionEvent event = Util.callCollisionEvent(npc, new Vector(x, y, z)); + NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z)); if (!event.isCancelled()) super.b_(x, y, z); // when another entity collides, b_ is called to push the NPC - // so we prevent b_ from doing anything. + // so we prevent b_ from doing anything if the event is cancelled. + } + + @Override + public void collide(net.minecraft.server.Entity entity) { + // 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); } @Override diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensIronGolemNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensIronGolemNPC.java index dcf9600e5..75729ad25 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensIronGolemNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensIronGolemNPC.java @@ -1,6 +1,6 @@ package net.citizensnpcs.npc.entity; -import net.citizensnpcs.api.event.NPCCollisionEvent; +import net.citizensnpcs.api.event.NPCPushEvent; import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.npc.CitizensMobNPC; import net.citizensnpcs.npc.CitizensNPC; @@ -42,13 +42,21 @@ public class CitizensIronGolemNPC extends CitizensMobNPC { super.b_(x, y, z); return; } - if (NPCCollisionEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) return; - NPCCollisionEvent event = Util.callCollisionEvent(npc, new Vector(x, y, z)); + NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z)); if (!event.isCancelled()) super.b_(x, y, z); // when another entity collides, b_ is called to push the NPC - // so we prevent b_ from doing anything. + // so we prevent b_ from doing anything if the event is cancelled. + } + + @Override + public void collide(net.minecraft.server.Entity entity) { + // 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); } @Override diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensMagmaCubeNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensMagmaCubeNPC.java index d950a1afa..30223b599 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensMagmaCubeNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensMagmaCubeNPC.java @@ -1,6 +1,6 @@ package net.citizensnpcs.npc.entity; -import net.citizensnpcs.api.event.NPCCollisionEvent; +import net.citizensnpcs.api.event.NPCPushEvent; import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.npc.CitizensMobNPC; import net.citizensnpcs.npc.CitizensNPC; @@ -47,13 +47,21 @@ public class CitizensMagmaCubeNPC extends CitizensMobNPC { super.b_(x, y, z); return; } - if (NPCCollisionEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) return; - NPCCollisionEvent event = Util.callCollisionEvent(npc, new Vector(x, y, z)); + NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z)); if (!event.isCancelled()) super.b_(x, y, z); // when another entity collides, b_ is called to push the NPC - // so we prevent b_ from doing anything. + // so we prevent b_ from doing anything if the event is cancelled. + } + + @Override + public void collide(net.minecraft.server.Entity entity) { + // 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); } @Override diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensMushroomCowNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensMushroomCowNPC.java index b49475d2f..94ac99054 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensMushroomCowNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensMushroomCowNPC.java @@ -1,6 +1,6 @@ package net.citizensnpcs.npc.entity; -import net.citizensnpcs.api.event.NPCCollisionEvent; +import net.citizensnpcs.api.event.NPCPushEvent; import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.npc.CitizensMobNPC; import net.citizensnpcs.npc.CitizensNPC; @@ -46,13 +46,21 @@ public class CitizensMushroomCowNPC extends CitizensMobNPC { super.b_(x, y, z); return; } - if (NPCCollisionEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) return; - NPCCollisionEvent event = Util.callCollisionEvent(npc, new Vector(x, y, z)); + NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z)); if (!event.isCancelled()) super.b_(x, y, z); // when another entity collides, b_ is called to push the NPC - // so we prevent b_ from doing anything. + // so we prevent b_ from doing anything if the event is cancelled. + } + + @Override + public void collide(net.minecraft.server.Entity entity) { + // 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); } @Override diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensOcelotNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensOcelotNPC.java index 618c1f13f..d86e0ddbf 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensOcelotNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensOcelotNPC.java @@ -1,6 +1,6 @@ package net.citizensnpcs.npc.entity; -import net.citizensnpcs.api.event.NPCCollisionEvent; +import net.citizensnpcs.api.event.NPCPushEvent; import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.npc.CitizensMobNPC; import net.citizensnpcs.npc.CitizensNPC; @@ -46,13 +46,21 @@ public class CitizensOcelotNPC extends CitizensMobNPC { super.b_(x, y, z); return; } - if (NPCCollisionEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) return; - NPCCollisionEvent event = Util.callCollisionEvent(npc, new Vector(x, y, z)); + NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z)); if (!event.isCancelled()) super.b_(x, y, z); // when another entity collides, b_ is called to push the NPC - // so we prevent b_ from doing anything. + // so we prevent b_ from doing anything if the event is cancelled. + } + + @Override + public void collide(net.minecraft.server.Entity entity) { + // 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); } @Override diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensPigNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensPigNPC.java index 5104d64f9..1a01f6311 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensPigNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensPigNPC.java @@ -1,6 +1,6 @@ package net.citizensnpcs.npc.entity; -import net.citizensnpcs.api.event.NPCCollisionEvent; +import net.citizensnpcs.api.event.NPCPushEvent; import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.editor.Equipable; import net.citizensnpcs.npc.CitizensMobNPC; @@ -79,13 +79,21 @@ public class CitizensPigNPC extends CitizensMobNPC implements Equipable { super.b_(x, y, z); return; } - if (NPCCollisionEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) return; - NPCCollisionEvent event = Util.callCollisionEvent(npc, new Vector(x, y, z)); + NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z)); if (!event.isCancelled()) super.b_(x, y, z); // when another entity collides, b_ is called to push the NPC - // so we prevent b_ from doing anything. + // so we prevent b_ from doing anything if the event is cancelled. + } + + @Override + public void collide(net.minecraft.server.Entity entity) { + // 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); } @Override diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensPigZombieNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensPigZombieNPC.java index 69a99f888..e95789d5b 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensPigZombieNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensPigZombieNPC.java @@ -1,6 +1,6 @@ package net.citizensnpcs.npc.entity; -import net.citizensnpcs.api.event.NPCCollisionEvent; +import net.citizensnpcs.api.event.NPCPushEvent; import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.npc.CitizensMobNPC; import net.citizensnpcs.npc.CitizensNPC; @@ -46,13 +46,21 @@ public class CitizensPigZombieNPC extends CitizensMobNPC { super.b_(x, y, z); return; } - if (NPCCollisionEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) return; - NPCCollisionEvent event = Util.callCollisionEvent(npc, new Vector(x, y, z)); + NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z)); if (!event.isCancelled()) super.b_(x, y, z); // when another entity collides, b_ is called to push the NPC - // so we prevent b_ from doing anything. + // so we prevent b_ from doing anything if the event is cancelled. + } + + @Override + public void collide(net.minecraft.server.Entity entity) { + // 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); } @Override diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensSheepNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensSheepNPC.java index 3992296a2..2a8b51e3a 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensSheepNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensSheepNPC.java @@ -1,6 +1,6 @@ package net.citizensnpcs.npc.entity; -import net.citizensnpcs.api.event.NPCCollisionEvent; +import net.citizensnpcs.api.event.NPCPushEvent; import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.editor.Equipable; import net.citizensnpcs.npc.CitizensMobNPC; @@ -84,13 +84,21 @@ public class CitizensSheepNPC extends CitizensMobNPC implements Equipable { super.b_(x, y, z); return; } - if (NPCCollisionEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) return; - NPCCollisionEvent event = Util.callCollisionEvent(npc, new Vector(x, y, z)); + NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z)); if (!event.isCancelled()) super.b_(x, y, z); // when another entity collides, b_ is called to push the NPC - // so we prevent b_ from doing anything. + // so we prevent b_ from doing anything if the event is cancelled. + } + + @Override + public void collide(net.minecraft.server.Entity entity) { + // 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); } @Override diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensSilverfishNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensSilverfishNPC.java index 4c0928991..dc07776f2 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensSilverfishNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensSilverfishNPC.java @@ -1,6 +1,6 @@ package net.citizensnpcs.npc.entity; -import net.citizensnpcs.api.event.NPCCollisionEvent; +import net.citizensnpcs.api.event.NPCPushEvent; import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.npc.CitizensMobNPC; import net.citizensnpcs.npc.CitizensNPC; @@ -46,13 +46,21 @@ public class CitizensSilverfishNPC extends CitizensMobNPC { super.b_(x, y, z); return; } - if (NPCCollisionEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) return; - NPCCollisionEvent event = Util.callCollisionEvent(npc, new Vector(x, y, z)); + NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z)); if (!event.isCancelled()) super.b_(x, y, z); // when another entity collides, b_ is called to push the NPC - // so we prevent b_ from doing anything. + // so we prevent b_ from doing anything if the event is cancelled. + } + + @Override + public void collide(net.minecraft.server.Entity entity) { + // 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); } @Override diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensSkeletonNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensSkeletonNPC.java index c94205215..4c16e2595 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensSkeletonNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensSkeletonNPC.java @@ -1,6 +1,6 @@ package net.citizensnpcs.npc.entity; -import net.citizensnpcs.api.event.NPCCollisionEvent; +import net.citizensnpcs.api.event.NPCPushEvent; import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.npc.CitizensMobNPC; import net.citizensnpcs.npc.CitizensNPC; @@ -46,13 +46,21 @@ public class CitizensSkeletonNPC extends CitizensMobNPC { super.b_(x, y, z); return; } - if (NPCCollisionEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) return; - NPCCollisionEvent event = Util.callCollisionEvent(npc, new Vector(x, y, z)); + NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z)); if (!event.isCancelled()) super.b_(x, y, z); // when another entity collides, b_ is called to push the NPC - // so we prevent b_ from doing anything. + // so we prevent b_ from doing anything if the event is cancelled. + } + + @Override + public void collide(net.minecraft.server.Entity entity) { + // 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); } @Override diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensSlimeNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensSlimeNPC.java index 94c399d4e..a7b586c00 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensSlimeNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensSlimeNPC.java @@ -1,6 +1,6 @@ package net.citizensnpcs.npc.entity; -import net.citizensnpcs.api.event.NPCCollisionEvent; +import net.citizensnpcs.api.event.NPCPushEvent; import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.npc.CitizensMobNPC; import net.citizensnpcs.npc.CitizensNPC; @@ -47,13 +47,21 @@ public class CitizensSlimeNPC extends CitizensMobNPC { super.b_(x, y, z); return; } - if (NPCCollisionEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) return; - NPCCollisionEvent event = Util.callCollisionEvent(npc, new Vector(x, y, z)); + NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z)); if (!event.isCancelled()) super.b_(x, y, z); // when another entity collides, b_ is called to push the NPC - // so we prevent b_ from doing anything. + // so we prevent b_ from doing anything if the event is cancelled. + } + + @Override + public void collide(net.minecraft.server.Entity entity) { + // 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); } @Override diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensSnowmanNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensSnowmanNPC.java index 5a4e21b70..2c125bbd3 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensSnowmanNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensSnowmanNPC.java @@ -1,6 +1,6 @@ package net.citizensnpcs.npc.entity; -import net.citizensnpcs.api.event.NPCCollisionEvent; +import net.citizensnpcs.api.event.NPCPushEvent; import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.npc.CitizensMobNPC; import net.citizensnpcs.npc.CitizensNPC; @@ -42,13 +42,21 @@ public class CitizensSnowmanNPC extends CitizensMobNPC { super.b_(x, y, z); return; } - if (NPCCollisionEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) return; - NPCCollisionEvent event = Util.callCollisionEvent(npc, new Vector(x, y, z)); + NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z)); if (!event.isCancelled()) super.b_(x, y, z); // when another entity collides, b_ is called to push the NPC - // so we prevent b_ from doing anything. + // so we prevent b_ from doing anything if the event is cancelled. + } + + @Override + public void collide(net.minecraft.server.Entity entity) { + // 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); } @Override diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensSpiderNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensSpiderNPC.java index fa0c0a093..821594ae8 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensSpiderNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensSpiderNPC.java @@ -1,6 +1,6 @@ package net.citizensnpcs.npc.entity; -import net.citizensnpcs.api.event.NPCCollisionEvent; +import net.citizensnpcs.api.event.NPCPushEvent; import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.npc.CitizensMobNPC; import net.citizensnpcs.npc.CitizensNPC; @@ -46,13 +46,21 @@ public class CitizensSpiderNPC extends CitizensMobNPC { super.b_(x, y, z); return; } - if (NPCCollisionEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) return; - NPCCollisionEvent event = Util.callCollisionEvent(npc, new Vector(x, y, z)); + NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z)); if (!event.isCancelled()) super.b_(x, y, z); // when another entity collides, b_ is called to push the NPC - // so we prevent b_ from doing anything. + // so we prevent b_ from doing anything if the event is cancelled. + } + + @Override + public void collide(net.minecraft.server.Entity entity) { + // 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); } @Override diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensSquidNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensSquidNPC.java index 5ca92b12d..55a9953bb 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensSquidNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensSquidNPC.java @@ -1,6 +1,6 @@ package net.citizensnpcs.npc.entity; -import net.citizensnpcs.api.event.NPCCollisionEvent; +import net.citizensnpcs.api.event.NPCPushEvent; import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.npc.CitizensMobNPC; import net.citizensnpcs.npc.CitizensNPC; @@ -46,13 +46,21 @@ public class CitizensSquidNPC extends CitizensMobNPC { super.b_(x, y, z); return; } - if (NPCCollisionEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) return; - NPCCollisionEvent event = Util.callCollisionEvent(npc, new Vector(x, y, z)); + NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z)); if (!event.isCancelled()) super.b_(x, y, z); // when another entity collides, b_ is called to push the NPC - // so we prevent b_ from doing anything. + // so we prevent b_ from doing anything if the event is cancelled. + } + + @Override + public void collide(net.minecraft.server.Entity entity) { + // 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); } @Override diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensVillagerNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensVillagerNPC.java index a37dbb0bd..40d18492e 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensVillagerNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensVillagerNPC.java @@ -1,6 +1,6 @@ package net.citizensnpcs.npc.entity; -import net.citizensnpcs.api.event.NPCCollisionEvent; +import net.citizensnpcs.api.event.NPCPushEvent; import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.npc.CitizensMobNPC; import net.citizensnpcs.npc.CitizensNPC; @@ -46,13 +46,21 @@ public class CitizensVillagerNPC extends CitizensMobNPC { super.b_(x, y, z); return; } - if (NPCCollisionEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) return; - NPCCollisionEvent event = Util.callCollisionEvent(npc, new Vector(x, y, z)); + NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z)); if (!event.isCancelled()) super.b_(x, y, z); // when another entity collides, b_ is called to push the NPC - // so we prevent b_ from doing anything. + // so we prevent b_ from doing anything if the event is cancelled. + } + + @Override + public void collide(net.minecraft.server.Entity entity) { + // 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); } @Override diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensWolfNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensWolfNPC.java index 2b74801af..72d443032 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensWolfNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensWolfNPC.java @@ -1,6 +1,6 @@ package net.citizensnpcs.npc.entity; -import net.citizensnpcs.api.event.NPCCollisionEvent; +import net.citizensnpcs.api.event.NPCPushEvent; import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.npc.CitizensMobNPC; import net.citizensnpcs.npc.CitizensNPC; @@ -46,13 +46,21 @@ public class CitizensWolfNPC extends CitizensMobNPC { super.b_(x, y, z); return; } - if (NPCCollisionEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) return; - NPCCollisionEvent event = Util.callCollisionEvent(npc, new Vector(x, y, z)); + NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z)); if (!event.isCancelled()) super.b_(x, y, z); // when another entity collides, b_ is called to push the NPC - // so we prevent b_ from doing anything. + // so we prevent b_ from doing anything if the event is cancelled. + } + + @Override + public void collide(net.minecraft.server.Entity entity) { + // 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); } @Override diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensZombieNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensZombieNPC.java index 342b3bb63..e3f06defa 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensZombieNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensZombieNPC.java @@ -1,6 +1,6 @@ package net.citizensnpcs.npc.entity; -import net.citizensnpcs.api.event.NPCCollisionEvent; +import net.citizensnpcs.api.event.NPCPushEvent; import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.npc.CitizensMobNPC; import net.citizensnpcs.npc.CitizensNPC; @@ -46,13 +46,21 @@ public class CitizensZombieNPC extends CitizensMobNPC { super.b_(x, y, z); return; } - if (NPCCollisionEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) return; - NPCCollisionEvent event = Util.callCollisionEvent(npc, new Vector(x, y, z)); + NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z)); if (!event.isCancelled()) super.b_(x, y, z); // when another entity collides, b_ is called to push the NPC - // so we prevent b_ from doing anything. + // so we prevent b_ from doing anything if the event is cancelled. + } + + @Override + public void collide(net.minecraft.server.Entity entity) { + // 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); } @Override diff --git a/src/main/java/net/citizensnpcs/npc/entity/EntityHumanNPC.java b/src/main/java/net/citizensnpcs/npc/entity/EntityHumanNPC.java index 455f0d70c..8140a1539 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/EntityHumanNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/EntityHumanNPC.java @@ -2,7 +2,7 @@ package net.citizensnpcs.npc.entity; import java.io.IOException; -import net.citizensnpcs.api.event.NPCCollisionEvent; +import net.citizensnpcs.api.event.NPCPushEvent; import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; @@ -52,13 +52,21 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder { super.b_(x, y, z); return; } - if (NPCCollisionEvent.getHandlerList().getRegisteredListeners().length == 0) + if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) return; - NPCCollisionEvent event = Util.callCollisionEvent(npc, new Vector(x, y, z)); + NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z)); if (!event.isCancelled()) super.b_(x, y, z); // when another entity collides, b_ is called to push the NPC - // so we prevent b_ from doing anything. + // so we prevent b_ from doing anything if the event is cancelled. + } + + @Override + public void collide(net.minecraft.server.Entity entity) { + // 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); } @Override diff --git a/src/main/java/net/citizensnpcs/util/Util.java b/src/main/java/net/citizensnpcs/util/Util.java index ca7dd035f..55d6129a7 100644 --- a/src/main/java/net/citizensnpcs/util/Util.java +++ b/src/main/java/net/citizensnpcs/util/Util.java @@ -8,6 +8,7 @@ import java.util.Map; import net.citizensnpcs.Settings.Setting; import net.citizensnpcs.api.event.NPCCollisionEvent; +import net.citizensnpcs.api.event.NPCPushEvent; import net.citizensnpcs.api.npc.NPC; import net.minecraft.server.Packet; @@ -32,8 +33,13 @@ public class Util { private static final Map, Class> primitiveClassMap = Maps.newHashMap(); - public static NPCCollisionEvent callCollisionEvent(NPC npc, Vector vector) { - NPCCollisionEvent event = new NPCCollisionEvent(npc, vector); + public static void callCollisionEvent(NPC npc, net.minecraft.server.Entity entity) { + if (NPCCollisionEvent.getHandlerList().getRegisteredListeners().length > 0) + Bukkit.getPluginManager().callEvent(new NPCCollisionEvent(npc, entity.getBukkitEntity())); + } + + public static NPCPushEvent callPushEvent(NPC npc, Vector vector) { + NPCPushEvent event = new NPCPushEvent(npc, vector); Bukkit.getPluginManager().callEvent(event); return event; }