Entity::spawnTo(): verify that the target player belongs to the same world as the entity

this should never be hit in the PM case, but it's an InvalidArgument rather than AssumptionFailedError because plugins can and do call this with bad things.
This commit is contained in:
Dylan K. Taylor 2021-10-29 18:54:00 +01:00
parent f1cc168d26
commit 089e62b44e
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
2 changed files with 4 additions and 1 deletions

View File

@ -563,7 +563,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
}
public function spawnTo(Player $player) : void{
if($this->spawned and $player->spawned and $this->isAlive() and $player->isAlive() and $player->getLevelNonNull() === $this->level and $player->canSee($this) and !$this->isSpectator()){
if($this->spawned and $player->spawned and $this->isAlive() and $player->isAlive() and $player->canSee($this) and !$this->isSpectator()){
parent::spawnTo($player);
}
}

View File

@ -1950,6 +1950,9 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
}
public function spawnTo(Player $player) : void{
if($player->getLevelNonNull() !== $this->level){
throw new \InvalidArgumentException("Player is not in the same world");
}
if(
!isset($this->hasSpawned[$player->getLoaderId()]) and
$this->chunk !== null and