Harden APIs which accept Vector3/Position/Location in event namespace

This commit is contained in:
Dylan K. Taylor
2022-03-09 22:22:37 +00:00
parent 879476d8e0
commit f97ce6afef
5 changed files with 35 additions and 0 deletions

View File

@ -27,6 +27,7 @@ use pocketmine\entity\Location;
use pocketmine\event\Cancellable;
use pocketmine\event\CancellableTrait;
use pocketmine\player\Player;
use pocketmine\utils\Utils;
class PlayerMoveEvent extends PlayerEvent implements Cancellable{
use CancellableTrait;
@ -51,6 +52,7 @@ class PlayerMoveEvent extends PlayerEvent implements Cancellable{
}
public function setTo(Location $to) : void{
Utils::checkLocationNotInfOrNaN($to);
$this->to = $to;
}
}

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace pocketmine\event\player;
use pocketmine\player\Player;
use pocketmine\utils\Utils;
use pocketmine\world\Position;
/**
@ -46,6 +47,7 @@ class PlayerRespawnEvent extends PlayerEvent{
if(!$position->isValid()){
throw new \InvalidArgumentException("Spawn position must reference a valid and loaded World");
}
Utils::checkVector3NotInfOrNaN($position);
$this->position = $position;
}
}