Added EntityTeleportEvent. Fixes BUKKIT-366

By: craftycreeper <diagonalfish+craftycreeper@gmail.com>
This commit is contained in:
Bukkit/Spigot 2012-02-07 23:42:43 -05:00
parent 202521ce54
commit b51e8579ef
2 changed files with 85 additions and 0 deletions

View File

@ -825,6 +825,12 @@ public abstract class Event implements Serializable {
* @see org.bukkit.event.entity.EndermanPlaceEvent
*/
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
*

View File

@ -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;
}
}