From 9642498d242f42911a5f1114e6a273042965c58d Mon Sep 17 00:00:00 2001 From: md_5 Date: Wed, 26 Dec 2018 08:00:00 +1100 Subject: [PATCH] SPIGOT-4547: Call EntitySpawnEvent as general spawn fallback event --- .../bukkit/craftbukkit/event/CraftEventFactory.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index a7d88fe6ac..54a6b98d47 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -383,6 +383,8 @@ public class CraftEventFactory { event = CraftEventFactory.callProjectileLaunchEvent(entity); } else if (entity.getBukkitEntity() instanceof org.bukkit.entity.Vehicle){ event = CraftEventFactory.callVehicleCreateEvent(entity); + } else { + event = CraftEventFactory.callEntitySpawnEvent(entity); } if (event != null && (event.isCancelled() || entity.dead)) { @@ -400,6 +402,17 @@ public class CraftEventFactory { return true; } + /** + * EntitySpawnEvent + */ + public static EntitySpawnEvent callEntitySpawnEvent(Entity entity) { + org.bukkit.entity.Entity bukkitEntity = entity.getBukkitEntity(); + + EntitySpawnEvent event = new EntitySpawnEvent(bukkitEntity); + bukkitEntity.getServer().getPluginManager().callEvent(event); + return event; + } + /** * CreatureSpawnEvent */