From e2779f623c75d6de64c3f3280b5ceaac01aa6223 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Tue, 21 Jun 2011 15:58:41 -0400 Subject: [PATCH] Added SpawnReasons to CreatureSpawn events. Thanks winsock! By: EvilSeph --- .../event/entity/CreatureSpawnEvent.java | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/paper-api/src/main/java/org/bukkit/event/entity/CreatureSpawnEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/CreatureSpawnEvent.java index 06621a0062..5761b87aee 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/CreatureSpawnEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/CreatureSpawnEvent.java @@ -13,11 +13,13 @@ public class CreatureSpawnEvent extends EntityEvent implements Cancellable { private Location location; private boolean canceled; private CreatureType creatureType; + private SpawnReason spawnReason; - public CreatureSpawnEvent(Entity spawnee, CreatureType mobtype, Location loc) { + public CreatureSpawnEvent(Entity spawnee, CreatureType mobtype, Location loc, SpawnReason spawnReason) { super(Type.CREATURE_SPAWN, spawnee); this.creatureType = mobtype; this.location = loc; + this.spawnReason = spawnReason; } /** @@ -56,4 +58,44 @@ public class CreatureSpawnEvent extends EntityEvent implements Cancellable { public CreatureType getCreatureType() { return creatureType; } + + /** + * Gets the reason for why the creature is being spawned. + * + * @return A SpawnReason value detailing the reason for the creature being spawned + */ + public SpawnReason getSpawnReason() { + return spawnReason; + } + + /** + * An enum to specify the type of spawning + */ + public enum SpawnReason { + + /** + * When something spawns from natural means + */ + NATURAL, + /** + * When a creature spawns from a spawner + */ + SPAWNER, + /** + * When a creature spawns from an egg + */ + EGG, + /** + * When a creature spawns because of a lightning strike + */ + LIGHTNING, + /** + * When a creature is spawned by a player that is sleeping + */ + BED, + /** + * When a creature is manually spawned + */ + CUSTOM + } }