diff options
Diffstat (limited to 'src/main/java')
4 files changed, 107 insertions, 2 deletions
diff --git a/src/main/java/org/bukkit/event/entity/EntityPortalEnterEvent.java b/src/main/java/org/bukkit/event/entity/EntityPortalEnterEvent.java index 384d5db4..87d57b01 100644 --- a/src/main/java/org/bukkit/event/entity/EntityPortalEnterEvent.java +++ b/src/main/java/org/bukkit/event/entity/EntityPortalEnterEvent.java @@ -5,7 +5,7 @@ import org.bukkit.Location; import org.bukkit.event.HandlerList; /** - * Stores data for entities standing inside a portal block + * Called when an entity comes into contact with a portal */ public class EntityPortalEnterEvent extends EntityEvent { private static final HandlerList handlers = new HandlerList(); diff --git a/src/main/java/org/bukkit/event/entity/EntityPortalEvent.java b/src/main/java/org/bukkit/event/entity/EntityPortalEvent.java new file mode 100644 index 00000000..8767243a --- /dev/null +++ b/src/main/java/org/bukkit/event/entity/EntityPortalEvent.java @@ -0,0 +1,47 @@ +package org.bukkit.event.entity; + +import org.bukkit.Location; +import org.bukkit.TravelAgent; +import org.bukkit.entity.Entity; +import org.bukkit.event.HandlerList; + +/** + * Called when a non-player entity is about to teleport because it is in contact with a portal + * <p /> + * For players see {@link org.bukkit.event.player.PlayerPortalEvent PlayerPortalEvent} + */ +public class EntityPortalEvent extends EntityTeleportEvent { + private static final HandlerList handlers = new HandlerList(); + protected boolean useTravelAgent = true; + protected TravelAgent travelAgent; + + public EntityPortalEvent(final Entity entity, final Location from, final Location to, final TravelAgent pta) { + super(entity, from, to); + this.travelAgent = pta; + } + + public void useTravelAgent(boolean useTravelAgent) { + this.useTravelAgent = useTravelAgent; + } + + public boolean useTravelAgent() { + return useTravelAgent; + } + + public TravelAgent getPortalTravelAgent() { + return this.travelAgent; + } + + public void setPortalTravelAgent(TravelAgent travelAgent) { + this.travelAgent = travelAgent; + } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } +}
\ No newline at end of file diff --git a/src/main/java/org/bukkit/event/entity/EntityPortalExitEvent.java b/src/main/java/org/bukkit/event/entity/EntityPortalExitEvent.java new file mode 100644 index 00000000..8e69e3be --- /dev/null +++ b/src/main/java/org/bukkit/event/entity/EntityPortalExitEvent.java @@ -0,0 +1,58 @@ +package org.bukkit.event.entity; + +import org.bukkit.Location; +import org.bukkit.entity.Entity; +import org.bukkit.event.HandlerList; +import org.bukkit.util.Vector; + +/** + * Called before an entity exits a portal. + * <p /> + * This event allows you to modify the velocity of the entity after they + * have successfully exeted the portal. + */ +public class EntityPortalExitEvent extends EntityTeleportEvent { + private static final HandlerList handlers = new HandlerList(); + private Vector before; + private Vector after; + + public EntityPortalExitEvent(final Entity entity, final Location from, final Location to, final Vector before, final Vector after) { + super(entity, from, to); + this.before = before; + this.after = after; + } + + /** + * Gets a copy of the velocity that the entity has before entering the portal. + * + * @return velocity of entity before entering portal + */ + public Vector getBefore() { + return this.before.clone(); + } + + /** + * Gets a copy of the velocity that the entity will have after exiting the portal. + * + * @return velocity of entity after exiting portal + */ + public Vector getAfter() { + return this.after.clone(); + } + + /** + * Sets the velocity that the entity will have after exiting the portal. + */ + public void setAfter(Vector after) { + this.after = after.clone(); + } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } +}
\ No newline at end of file diff --git a/src/main/java/org/bukkit/event/player/PlayerPortalEvent.java b/src/main/java/org/bukkit/event/player/PlayerPortalEvent.java index a243b538..1114f5c7 100644 --- a/src/main/java/org/bukkit/event/player/PlayerPortalEvent.java +++ b/src/main/java/org/bukkit/event/player/PlayerPortalEvent.java @@ -6,7 +6,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; /** - * Called when a player completes the portaling process by standing in a portal + * Called when a player is about to teleport because it is in contact with a portal */ public class PlayerPortalEvent extends PlayerTeleportEvent { private static final HandlerList handlers = new HandlerList(); |