Entity: spawnTo() must silently swallow errors

Player->showPlayer() assumes that spawnTo() will take care of all the checks necessary to ensure we don't actually spawn a player to someone it shouldn't be able to see. In PM3, there's nothing we can do about that.
This could be a problem if anything decides to override spawnTo() to do additional stuff and assumes that the function will always succeed; however, there's not much reason to do that (plugins sending packets should override sendSpawnPacket() instead).
This commit is contained in:
Dylan K. Taylor 2021-10-30 15:38:27 +01:00
parent d17cd65803
commit 71f2a34616
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -1950,12 +1950,10 @@ 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
$player->getLevelNonNull() === $this->level and
isset($player->usedChunks[$chunkHash = Level::chunkHash($this->chunk->getX(), $this->chunk->getZ())]) and
$player->usedChunks[$chunkHash] === true
){