summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorcraftycreeper <diagonalfish+craftycreeper@gmail.com>2012-02-07 23:42:43 -0500
committerEvilSeph <evilseph@gmail.com>2012-02-09 03:20:08 -0500
commit4272a879f925950f18ddcdeffe124ba9c43e0095 (patch)
tree88b99af2136b6c117a2ff40fa1b8d28bab1a0c11 /src
parentd9ed0a0d33a7f5a80e00a11697e41a27dd22a325 (diff)
downloadbukkit-4272a879f925950f18ddcdeffe124ba9c43e0095.tar
bukkit-4272a879f925950f18ddcdeffe124ba9c43e0095.tar.gz
bukkit-4272a879f925950f18ddcdeffe124ba9c43e0095.tar.lz
bukkit-4272a879f925950f18ddcdeffe124ba9c43e0095.tar.xz
bukkit-4272a879f925950f18ddcdeffe124ba9c43e0095.zip
Added EntityTeleportEvent. Fixes BUKKIT-366
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/bukkit/event/Event.java6
-rw-r--r--src/main/java/org/bukkit/event/entity/EntityTeleportEvent.java79
2 files changed, 85 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/event/Event.java b/src/main/java/org/bukkit/event/Event.java
index 8a5035d8..448827b9 100644
--- a/src/main/java/org/bukkit/event/Event.java
+++ b/src/main/java/org/bukkit/event/Event.java
@@ -826,6 +826,12 @@ public abstract class Event implements Serializable {
*/
ENDERMAN_PLACE(Category.LIVING_ENTITY, EndermanPlaceEvent.class),
/**
+ * Called when a non-player LivingEntity teleports
+ *
+ * @see org.bukkit.event.entity.EntityTeleportEvent
+ */
+ ENTITY_TELEPORT(Category.LIVING_ENTITY, EntityTeleportEvent.class),
+ /**
* Called when a human entity's food level changes
*
* @see org.bukkit.event.entity.FoodLevelChangeEvent
diff --git a/src/main/java/org/bukkit/event/entity/EntityTeleportEvent.java b/src/main/java/org/bukkit/event/entity/EntityTeleportEvent.java
new file mode 100644
index 00000000..bc588043
--- /dev/null
+++ b/src/main/java/org/bukkit/event/entity/EntityTeleportEvent.java
@@ -0,0 +1,79 @@
+package org.bukkit.event.entity;
+
+import org.bukkit.Location;
+import org.bukkit.entity.Entity;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+
+/**
+ * Thrown when a non-player entity (such as an Enderman) tries to teleport from one
+ * location to another.
+ */
+@SuppressWarnings("serial")
+public class EntityTeleportEvent extends EntityEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+
+ private boolean cancel;
+ private Location from;
+ private Location to;
+
+ public EntityTeleportEvent(Entity what, Location from, Location to) {
+ super(Type.ENTITY_TELEPORT, what);
+ this.from = from;
+ this.to = to;
+ this.cancel = false;
+ }
+
+ public boolean isCancelled() {
+ return cancel;
+ }
+
+ public void setCancelled(boolean cancel) {
+ this.cancel = cancel;
+ }
+
+ /**
+ * Gets the location that this entity moved from
+ *
+ * @return Location this entity moved from
+ */
+ public Location getFrom() {
+ return from;
+ }
+
+ /**
+ * Sets the location that this entity moved from
+ *
+ * @param from New location this entity moved from
+ */
+ public void setFrom(Location from) {
+ this.from = from;
+ }
+
+ /**
+ * Gets the location that this entity moved to
+ *
+ * @return Location the entity moved to
+ */
+ public Location getTo() {
+ return to;
+ }
+
+ /**
+ * Sets the location that this entity moved to
+ *
+ * @param to New Location this entity moved to
+ */
+ public void setTo(Location to) {
+ this.to = to;
+ }
+
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+} \ No newline at end of file