Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
EntityPortalEvent.java
1 package org.bukkit.event.entity;
2 
3 import org.bukkit.Location;
4 import org.bukkit.TravelAgent;
5 import org.bukkit.entity.Entity;
7 
8 /**
9  * Called when a non-player entity is about to teleport because it is in
10  * contact with a portal.
11  * <p>
12  * For players see {@link org.bukkit.event.player.PlayerPortalEvent}
13  */
14 public class EntityPortalEvent extends EntityTeleportEvent {
15  private static final HandlerList handlers = new HandlerList();
16  protected boolean useTravelAgent = true;
17  protected TravelAgent travelAgent;
18 
19  public EntityPortalEvent(final Entity entity, final Location from, final Location to, final TravelAgent pta) {
20  super(entity, from, to);
21  this.travelAgent = pta;
22  }
23 
24  /**
25  * Sets whether or not the Travel Agent will be used.
26  * <p>
27  * If this is set to true, the TravelAgent will try to find a Portal at
28  * the {@link #getTo()} Location, and will try to create one if there is
29  * none.
30  * <p>
31  * If this is set to false, the {@link #getEntity()} will only be
32  * teleported to the {@link #getTo()} Location.
33  *
34  * @param useTravelAgent whether to use the Travel Agent
35  */
36  public void useTravelAgent(boolean useTravelAgent) {
37  this.useTravelAgent = useTravelAgent;
38  }
39 
40  /**
41  * Gets whether or not the Travel Agent will be used.
42  * <p>
43  * If this is set to true, the TravelAgent will try to find a Portal at
44  * the {@link #getTo()} Location, and will try to create one if there is
45  * none.
46  * <p>
47  * If this is set to false, the {@link #getEntity()} will only be
48  * teleported to the {@link #getTo()} Location.
49  *
50  * @return whether to use the Travel Agent
51  */
52  public boolean useTravelAgent() {
53  return useTravelAgent;
54  }
55 
56  /**
57  * Gets the Travel Agent used (or not) in this event.
58  *
59  * @return the Travel Agent used (or not) in this event
60  */
62  return this.travelAgent;
63  }
64 
65  /**
66  * Sets the Travel Agent used (or not) in this event.
67  *
68  * @param travelAgent the Travel Agent used (or not) in this event
69  */
70  public void setPortalTravelAgent(TravelAgent travelAgent) {
71  this.travelAgent = travelAgent;
72  }
73 
74  @Override
75  public HandlerList getHandlers() {
76  return handlers;
77  }
78 
79  public static HandlerList getHandlerList() {
80  return handlers;
81  }
82 }
void setPortalTravelAgent(TravelAgent travelAgent)
void useTravelAgent(boolean useTravelAgent)