summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorss2man44 <frigids@gmail.com>2011-01-11 21:29:48 -0500
committerEvilSeph <evilseph@unaligned.org>2011-02-16 22:28:44 -0500
commit93f6e5191efacef52739c15c9bed81f3c9ef2f85 (patch)
treed95ba1b326332be03ae04c64b592182514c4a4de /src
parente345a982eb7011e14c12538f6e1118cca18cf54b (diff)
downloadbukkit-93f6e5191efacef52739c15c9bed81f3c9ef2f85.tar
bukkit-93f6e5191efacef52739c15c9bed81f3c9ef2f85.tar.gz
bukkit-93f6e5191efacef52739c15c9bed81f3c9ef2f85.tar.lz
bukkit-93f6e5191efacef52739c15c9bed81f3c9ef2f85.tar.xz
bukkit-93f6e5191efacef52739c15c9bed81f3c9ef2f85.zip
Added CREATURE_SPAWN event
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/bukkit/event/entity/CreatureSpawnEvent.java66
-rw-r--r--src/main/java/org/bukkit/event/entity/EntityListener.java3
-rw-r--r--src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java5
3 files changed, 74 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/event/entity/CreatureSpawnEvent.java b/src/main/java/org/bukkit/event/entity/CreatureSpawnEvent.java
new file mode 100644
index 00000000..b84b78cf
--- /dev/null
+++ b/src/main/java/org/bukkit/event/entity/CreatureSpawnEvent.java
@@ -0,0 +1,66 @@
+package org.bukkit.event.entity;
+
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.MobType;
+import org.bukkit.Location;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.Event;
+
+/**
+ * Stores data for damage events
+ */
+public class CreatureSpawnEvent extends EntityEvent implements Cancellable {
+
+ private Location location;
+ private boolean canceled;
+ private MobType mobtype;
+
+ public CreatureSpawnEvent(Entity spawnee, MobType mobtype, Location loc) {
+ super(Event.Type.CREATURE_SPAWN, spawnee);
+ this.mobtype = mobtype;
+ this.location = loc;
+ }
+
+ protected CreatureSpawnEvent(Event.Type type, Entity spawnee, MobType mobtype, Location loc) {
+ super(type, spawnee);
+ this.mobtype = mobtype;
+ this.location = loc;
+ }
+
+ /**
+ * Gets the cancellation state of this event. A canceled event will not
+ * be executed in the server, but will still pass to other plugins
+ *
+ * @return true if this event is canceled
+ */
+ public boolean isCancelled() {
+ return canceled;
+ }
+
+ /**
+ * Sets the cancellation state of this event. A canceled event will not
+ * be executed in the server, but will still pass to other plugins
+ *
+ * @param cancel true if you wish to cancel this event
+ */
+ public void setCancelled(boolean cancel) {
+ canceled = cancel;
+ }
+
+ /**
+ * Gets the location at which the creature is spawning.
+ * @return The location at which the creature is spawning
+ */
+ public Location getLocation() {
+ return location;
+ }
+
+ /**
+ * Gets the type of creature being spawned.
+ *
+ * @return A CreatureType value detailing the type of creature being spawned
+ */
+ public MobType getMobType() {
+ return mobtype;
+ }
+} \ No newline at end of file
diff --git a/src/main/java/org/bukkit/event/entity/EntityListener.java b/src/main/java/org/bukkit/event/entity/EntityListener.java
index fbc238b9..d4595957 100644
--- a/src/main/java/org/bukkit/event/entity/EntityListener.java
+++ b/src/main/java/org/bukkit/event/entity/EntityListener.java
@@ -9,6 +9,9 @@ public class EntityListener implements Listener {
public EntityListener() {
}
+ public void onCreatureSpawn(CreatureSpawnEvent event) {
+ }
+
public void onEntityDamageByBlock(EntityDamageByBlockEvent event) {
}
diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
index 2c721eee..e82b9590 100644
--- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
+++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
@@ -358,6 +358,11 @@ public final class JavaPluginLoader implements PluginLoader {
((EntityListener)listener).onEntityTarget( (EntityTargetEvent)event );
}
};
+ case CREATURE_SPAWN:
+ return new EventExecutor() { public void execute( Listener listener, Event event ) {
+ ((EntityListener)listener).onCreatureSpawn( (CreatureSpawnEvent)event );
+ }
+ };
// Vehicle Events
case VEHICLE_CREATE: