Commits

md_5 authored 8deca8c9aaa
SPIGOT-859: Ensure plugins cannot set locations without worlds in move events.
No tags

src/main/java/org/bukkit/event/player/PlayerMoveEvent.java

Modified
1 1 package org.bukkit.event.player;
2 2
3 +import com.google.common.base.Preconditions;
3 4 import org.bukkit.Location;
4 5 import org.bukkit.entity.Player;
5 6 import org.bukkit.event.Cancellable;
6 7 import org.bukkit.event.HandlerList;
7 8
8 9 /**
9 10 * Holds information for player movement events
10 11 */
11 12 public class PlayerMoveEvent extends PlayerEvent implements Cancellable {
12 13 private static final HandlerList handlers = new HandlerList();
56 57 public Location getFrom() {
57 58 return from;
58 59 }
59 60
60 61 /**
61 62 * Sets the location to mark as where the player moved from
62 63 *
63 64 * @param from New location to mark as the players previous location
64 65 */
65 66 public void setFrom(Location from) {
67 + validateLocation(to);
66 68 this.from = from;
67 69 }
68 70
69 71 /**
70 72 * Gets the location this player moved to
71 73 *
72 74 * @return Location the player moved to
73 75 */
74 76 public Location getTo() {
75 77 return to;
76 78 }
77 79
78 80 /**
79 81 * Sets the location that this player will move to
80 82 *
81 83 * @param to New Location this player will move to
82 84 */
83 85 public void setTo(Location to) {
86 + validateLocation(to);
84 87 this.to = to;
85 88 }
86 89
90 + private void validateLocation(Location loc) {
91 + Preconditions.checkArgument(loc != null, "Cannot use location with null world!");
92 + }
93 +
87 94 @Override
88 95 public HandlerList getHandlers() {
89 96 return handlers;
90 97 }
91 98
92 99 public static HandlerList getHandlerList() {
93 100 return handlers;
94 101 }
95 102 }

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut