001 package org.bukkit.event.entity;
002
003 import org.bukkit.Location;
004 import org.bukkit.entity.Entity;
005 import org.bukkit.event.HandlerList;
006 import org.bukkit.util.Vector;
007
008 /**
009 * Called before an entity exits a portal.
010 * <p>
011 * This event allows you to modify the velocity of the entity after they have
012 * successfully exited the portal.
013 */
014 public class EntityPortalExitEvent extends EntityTeleportEvent {
015 private static final HandlerList handlers = new HandlerList();
016 private Vector before;
017 private Vector after;
018
019 public EntityPortalExitEvent(final Entity entity, final Location from, final Location to, final Vector before, final Vector after) {
020 super(entity, from, to);
021 this.before = before;
022 this.after = after;
023 }
024
025 /**
026 * Gets a copy of the velocity that the entity has before entering the
027 * portal.
028 *
029 * @return velocity of entity before entering portal
030 */
031 public Vector getBefore() {
032 return this.before.clone();
033 }
034
035 /**
036 * Gets a copy of the velocity that the entity will have after exiting the
037 * portal.
038 *
039 * @return velocity of entity after exiting portal
040 */
041 public Vector getAfter() {
042 return this.after.clone();
043 }
044
045 /**
046 * Sets the velocity that the entity will have after exiting the portal.
047 */
048 public void setAfter(Vector after) {
049 this.after = after.clone();
050 }
051
052 @Override
053 public HandlerList getHandlers() {
054 return handlers;
055 }
056
057 public static HandlerList getHandlerList() {
058 return handlers;
059 }
060 }