From 9e46607f98b42959468605a8475803f16218fa3a Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Tue, 21 Jun 2011 16:20:11 -0400 Subject: [PATCH] Added SpawnReasons to CreatureSpawn events. Thanks winsock! By: EvilSeph --- .../src/main/java/org/bukkit/craftbukkit/CraftWorld.java | 3 ++- .../java/org/bukkit/craftbukkit/event/CraftEventFactory.java | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 4f08d39483..d019e00b7b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -12,6 +12,7 @@ import net.minecraft.server.*; import org.bukkit.entity.Arrow; import org.bukkit.Effect; +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import org.bukkit.event.weather.WeatherChangeEvent; import org.bukkit.event.weather.ThunderChangeEvent; import org.bukkit.event.world.SpawnChangeEvent; @@ -346,7 +347,7 @@ public class CraftWorld implements World { EntityLiving entityCreature = (EntityLiving) EntityTypes.a(creatureType.getName(), world); entityCreature.setPosition(loc.getX(), loc.getY(), loc.getZ()); creature = (LivingEntity) CraftEntity.getEntity(server, entityCreature); - world.addEntity(entityCreature); + world.addEntity(entityCreature, SpawnReason.CUSTOM); } catch (Exception e) { // if we fail, for any reason, return null. creature = null; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 474cd3f460..bb6baac87d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -41,6 +41,7 @@ import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockDamageEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import org.bukkit.event.entity.EntityTameEvent; import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.player.PlayerBucketEmptyEvent; @@ -190,7 +191,7 @@ public class CraftEventFactory { /** * CreatureSpawnEvent */ - public static CreatureSpawnEvent callCreatureSpawnEvent(EntityLiving entityliving) { + public static CreatureSpawnEvent callCreatureSpawnEvent(EntityLiving entityliving, SpawnReason spawnReason) { org.bukkit.entity.Entity entity = entityliving.getBukkitEntity(); CraftServer craftServer = (CraftServer) entity.getServer(); @@ -229,7 +230,7 @@ public class CraftEventFactory { type = CreatureType.MONSTER; } - CreatureSpawnEvent event = new CreatureSpawnEvent(entity, type, entity.getLocation()); + CreatureSpawnEvent event = new CreatureSpawnEvent(entity, type, entity.getLocation(), spawnReason); craftServer.getPluginManager().callEvent(event); return event; }