Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
PlayerMoveEvent.java
1 package org.bukkit.event.player;
2 
3 import org.bukkit.Location;
4 import org.bukkit.entity.Player;
7 
8 /**
9  * Holds information for player movement events
10  */
11 public class PlayerMoveEvent extends PlayerEvent implements Cancellable {
12  private static final HandlerList handlers = new HandlerList();
13  private boolean cancel = false;
14  private Location from;
15  private Location to;
16 
17  public PlayerMoveEvent(final Player player, final Location from, final Location to) {
18  super(player);
19  this.from = from;
20  this.to = to;
21  }
22 
23  /**
24  * Gets the cancellation state of this event. A cancelled event will not
25  * be executed in the server, but will still pass to other plugins
26  * <p>
27  * If a move or teleport event is cancelled, the player will be moved or
28  * teleported back to the Location as defined by getFrom(). This will not
29  * fire an event
30  *
31  * @return true if this event is cancelled
32  */
33  public boolean isCancelled() {
34  return cancel;
35  }
36 
37  /**
38  * Sets the cancellation state of this event. A cancelled event will not
39  * be executed in the server, but will still pass to other plugins
40  * <p>
41  * If a move or teleport event is cancelled, the player will be moved or
42  * teleported back to the Location as defined by getFrom(). This will not
43  * fire an event
44  *
45  * @param cancel true if you wish to cancel this event
46  */
47  public void setCancelled(boolean cancel) {
48  this.cancel = cancel;
49  }
50 
51  /**
52  * Gets the location this player moved from
53  *
54  * @return Location the player moved from
55  */
56  public Location getFrom() {
57  return from;
58  }
59 
60  /**
61  * Sets the location to mark as where the player moved from
62  *
63  * @param from New location to mark as the players previous location
64  */
65  public void setFrom(Location from) {
66  this.from = from;
67  }
68 
69  /**
70  * Gets the location this player moved to
71  *
72  * @return Location the player moved to
73  */
74  public Location getTo() {
75  return to;
76  }
77 
78  /**
79  * Sets the location that this player will move to
80  *
81  * @param to New Location this player will move to
82  */
83  public void setTo(Location to) {
84  this.to = to;
85  }
86 
87  @Override
88  public HandlerList getHandlers() {
89  return handlers;
90  }
91 
92  public static HandlerList getHandlerList() {
93  return handlers;
94  }
95 }