Added EntityTeleportEvent. Fixes BUKKIT-366
This commit is contained in:
parent
d9ed0a0d33
commit
4272a879f9
@ -825,6 +825,12 @@ public abstract class Event implements Serializable {
|
|||||||
* @see org.bukkit.event.entity.EndermanPlaceEvent
|
* @see org.bukkit.event.entity.EndermanPlaceEvent
|
||||||
*/
|
*/
|
||||||
ENDERMAN_PLACE(Category.LIVING_ENTITY, EndermanPlaceEvent.class),
|
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
|
* Called when a human entity's food level changes
|
||||||
*
|
*
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user