SPIGOT-859: Ensure plugins cannot set locations without worlds in move events.

By: md_5 <git@md-5.net>
This commit is contained in:
Bukkit/Spigot 2015-05-21 17:10:29 +10:00
parent 745401c988
commit a0022c54d1

View file

@ -1,5 +1,6 @@
package org.bukkit.event.player;
import com.google.common.base.Preconditions;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
@ -63,6 +64,7 @@ public class PlayerMoveEvent extends PlayerEvent implements Cancellable {
* @param from New location to mark as the players previous location
*/
public void setFrom(Location from) {
validateLocation(to);
this.from = from;
}
@ -81,9 +83,14 @@ public class PlayerMoveEvent extends PlayerEvent implements Cancellable {
* @param to New Location this player will move to
*/
public void setTo(Location to) {
validateLocation(to);
this.to = to;
}
private void validateLocation(Location loc) {
Preconditions.checkArgument(loc != null, "Cannot use location with null world!");
}
@Override
public HandlerList getHandlers() {
return handlers;