001    package org.bukkit.event.entity;
002    
003    import org.bukkit.Location;
004    import org.bukkit.entity.Entity;
005    import org.bukkit.event.Cancellable;
006    import org.bukkit.event.HandlerList;
007    
008    /**
009     * Thrown when a non-player entity (such as an Enderman) tries to teleport
010     * from one location to another.
011     */
012    public class EntityTeleportEvent extends EntityEvent implements Cancellable {
013        private static final HandlerList handlers = new HandlerList();
014        private boolean cancel;
015        private Location from;
016        private Location to;
017    
018        public EntityTeleportEvent(Entity what, Location from, Location to) {
019            super(what);
020            this.from = from;
021            this.to = to;
022            this.cancel = false;
023        }
024    
025        public boolean isCancelled() {
026            return cancel;
027        }
028    
029        public void setCancelled(boolean cancel) {
030            this.cancel = cancel;
031        }
032    
033        /**
034         * Gets the location that this entity moved from
035         *
036         * @return Location this entity moved from
037         */
038        public Location getFrom() {
039            return from;
040        }
041    
042        /**
043         * Sets the location that this entity moved from
044         *
045         * @param from New location this entity moved from
046         */
047        public void setFrom(Location from) {
048            this.from = from;
049        }
050    
051        /**
052         * Gets the location that this entity moved to
053         *
054         * @return Location the entity moved to
055         */
056        public Location getTo() {
057            return to;
058        }
059    
060        /**
061         * Sets the location that this entity moved to
062         *
063         * @param to New Location this entity moved to
064         */
065        public void setTo(Location to) {
066            this.to = to;
067        }
068    
069        @Override
070        public HandlerList getHandlers() {
071            return handlers;
072        }
073    
074        public static HandlerList getHandlerList() {
075            return handlers;
076        }
077    }