Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
1package org.bukkit.event.entity;
2
3import org.bukkit.Location;
4import org.bukkit.entity.CreatureType;
5import org.bukkit.entity.Entity;
6import org.bukkit.event.Cancellable;
7
8/**
9 * Called when a creature is spawned into a world.
10 * <p/>
11 * If a Creature Spawn event is cancelled, the creature will not spawn.
12 */
13public class CreatureSpawnEvent extends EntityEvent implements Cancellable {
14
15 private Location location;
16 private boolean canceled;
17 private CreatureType creatureType;
18 private SpawnReason spawnReason;
19
20 public CreatureSpawnEvent(Entity spawnee, CreatureType mobtype, Location loc, SpawnReason spawnReason) {
21 super(Type.CREATURE_SPAWN, spawnee);
22 this.creatureType = mobtype;
23 this.location = loc;
24 this.spawnReason = spawnReason;
25 }
26
27 public boolean isCancelled() {
28 return canceled;
29 }
30
31 public void setCancelled(boolean cancel) {
32 canceled = cancel;
33 }
34
35 /**
36 * Gets the location at which the creature is spawning.
37 *
38 * @return The location at which the creature is spawning
39 */
40 public Location getLocation() {
41 return location;
42 }
43
44 /**
45 * Gets the type of creature being spawned.
46 *
47 * @return A CreatureType value detailing the type of creature being spawned
48 */
49 public CreatureType getCreatureType() {
50 return creatureType;
51 }
52
53 /**
54 * Gets the reason for why the creature is being spawned.
55 *
56 * @return A SpawnReason value detailing the reason for the creature being spawned
57 */
58 public SpawnReason getSpawnReason() {
59 return spawnReason;
60 }
61
62 /**
63 * An enum to specify the type of spawning
64 */
65 public enum SpawnReason {
66
67 /**
68 * When something spawns from natural means
69 */
70 NATURAL,
71 /**
72 * When a creature spawns from a spawner
73 */
74 SPAWNER,
75 /**
76 * When a creature spawns from an egg
77 */
78 EGG,
79 /**
80 * When a creature spawns because of a lightning strike
81 */
82 LIGHTNING,
83 /**
84 * When a creature is spawned by a player that is sleeping
85 */
86 BED,
87 /**
88 * When a creature is manually spawned
89 */
90 CUSTOM
91 }
92}