mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 03:43:40 +01:00
SPIGOT-859: Ensure plugins cannot set locations without worlds in move events.
By: md_5 <git@md-5.net>
This commit is contained in:
parent
745401c988
commit
a0022c54d1
1 changed files with 7 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue