mirror of
https://hub.spigotmc.org/stash/scm/spigot/bukkit.git
synced 2025-08-21 05:44:17 +00:00
SPIGOT-859: Ensure plugins cannot set locations without worlds in move events.
This commit is contained in:
parent
b333b58c05
commit
8deca8c9aa
1 changed files with 7 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
||||||
package org.bukkit.event.player;
|
package org.bukkit.event.player;
|
||||||
|
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Cancellable;
|
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
|
* @param from New location to mark as the players previous location
|
||||||
*/
|
*/
|
||||||
public void setFrom(Location from) {
|
public void setFrom(Location from) {
|
||||||
|
validateLocation(to);
|
||||||
this.from = from;
|
this.from = from;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,9 +83,14 @@ public class PlayerMoveEvent extends PlayerEvent implements Cancellable {
|
||||||
* @param to New Location this player will move to
|
* @param to New Location this player will move to
|
||||||
*/
|
*/
|
||||||
public void setTo(Location to) {
|
public void setTo(Location to) {
|
||||||
|
validateLocation(to);
|
||||||
this.to = to;
|
this.to = to;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void validateLocation(Location loc) {
|
||||||
|
Preconditions.checkArgument(loc != null, "Cannot use location with null world!");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
|
|
Loading…
Add table
Reference in a new issue