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