From 1e2038fac57a4f79380e05de0f6d3e040cab8db7 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Fri, 29 May 2015 10:04:26 +0200 Subject: [PATCH] Faster respawn when needed --- src/pocketmine/Player.php | 3 +-- src/pocketmine/entity/Entity.php | 7 +++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 6e2ad2f5d..41d7747b1 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -562,8 +562,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade public function setSkin($str, $isSlim = false){ parent::setSkin($str, $isSlim); if($this->spawned === true){ - $this->despawnFromAll(); - $this->spawnToAll(); + $this->respawnToAll(); } } diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index 0923942f3..dbd9a996e 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -1465,6 +1465,13 @@ abstract class Entity extends Location implements Metadatable{ return $this->id; } + public function respawnToAll(){ + foreach($this->hasSpawned as $key => $player){ + unset($this->hasSpawned[$key]); + $this->spawnTo($player); + } + } + public function spawnToAll(){ if($this->chunk === null){ return;