summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormd_5 <git@md-5.net>2015-05-21 17:10:29 +1000
committermd_5 <git@md-5.net>2015-05-21 17:10:29 +1000
commit8deca8c9aaadc4f45b3ed27349ceb51be24a9f1c (patch)
tree719d6af1e3f4874ab528f9a36c14661959d12297
parentb333b58c05a0392f3fcf825028c058518a50d1c7 (diff)
downloadbukkit-8deca8c9aaadc4f45b3ed27349ceb51be24a9f1c.tar
bukkit-8deca8c9aaadc4f45b3ed27349ceb51be24a9f1c.tar.gz
bukkit-8deca8c9aaadc4f45b3ed27349ceb51be24a9f1c.tar.lz
bukkit-8deca8c9aaadc4f45b3ed27349ceb51be24a9f1c.tar.xz
bukkit-8deca8c9aaadc4f45b3ed27349ceb51be24a9f1c.zip
SPIGOT-859: Ensure plugins cannot set locations without worlds in move events.
-rw-r--r--src/main/java/org/bukkit/event/player/PlayerMoveEvent.java7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/event/player/PlayerMoveEvent.java b/src/main/java/org/bukkit/event/player/PlayerMoveEvent.java
index fa3b340e..8debcda7 100644
--- a/src/main/java/org/bukkit/event/player/PlayerMoveEvent.java
+++ b/src/main/java/org/bukkit/event/player/PlayerMoveEvent.java
@@ -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;