diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9ba874512..aa42903b7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -253,10 +253,10 @@ jobs: - uses: actions/checkout@v2 - name: Setup PHP and tools - uses: shivammathur/setup-php@2.9.0 + uses: shivammathur/setup-php@2.15.0 with: php-version: 8.0 - tools: php-cs-fixer + tools: php-cs-fixer:3.2 - name: Run PHP-CS-Fixer run: php-cs-fixer fix --dry-run --diff diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 659d76748..8d6d98c4b 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -61,6 +61,11 @@ return (new PhpCsFixer\Config) ], 'sort_algorithm' => 'alpha' ], + 'phpdoc_line_span' => [ + 'property' => 'single', + 'method' => null, + 'const' => null + ], 'phpdoc_trim' => true, 'phpdoc_trim_consecutive_blank_line_separation' => true, 'single_import_per_statement' => true, diff --git a/src/entity/Entity.php b/src/entity/Entity.php index c917f6001..9d9382b4a 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -1436,6 +1436,9 @@ abstract class Entity{ } public function spawnTo(Player $player) : void{ + if($player->getWorld() !== $this->getWorld()){ + throw new \InvalidArgumentException("Player is not in the same world"); + } $id = spl_object_id($player); //TODO: this will cause some visible lag during chunk resends; if the player uses a spawn egg in a chunk, the //created entity won't be visible until after the resend arrives. However, this is better than possibly crashing diff --git a/src/player/Player.php b/src/player/Player.php index 8a8ba1ce2..33c61b302 100644 --- a/src/player/Player.php +++ b/src/player/Player.php @@ -394,7 +394,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{ } public function spawnTo(Player $player) : void{ - if($this->isAlive() and $player->isAlive() and $player->getWorld() === $this->getWorld() and $player->canSee($this) and !$this->isSpectator()){ + if($this->isAlive() and $player->isAlive() and $player->canSee($this) and !$this->isSpectator()){ parent::spawnTo($player); } }