From 670a9fe44ff16e6f890d69d1560416d8dfdc72e0 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 17 Aug 2017 10:29:12 +0100 Subject: [PATCH] Fix some crashy issues when incompatible players get disconnected --- src/pocketmine/Player.php | 10 ++++++---- src/pocketmine/entity/Entity.php | 4 ++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index b610f4b49..ec20eb369 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -247,9 +247,9 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ protected $ip; protected $removeFormat = true; protected $port; - protected $username; - protected $iusername; - protected $displayName; + protected $username = ""; + protected $iusername = ""; + protected $displayName = ""; protected $startAction = -1; /** @var Vector3|null */ protected $sleeping = null; @@ -3472,7 +3472,9 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ $this->windows = null; $this->windowIndex = []; - parent::close(); + if($this->constructed){ + parent::close(); + } $this->spawned = false; if($this->loggedIn){ diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index f061728cd..9220e4ad2 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -359,8 +359,12 @@ abstract class Entity extends Location implements Metadatable{ /** @var bool */ protected $isPlayer = false; + /** @var bool */ + protected $constructed = false; + public function __construct(Level $level, CompoundTag $nbt){ + $this->constructed = true; $this->timings = Timings::getEntityTimings($this); $this->isPlayer = $this instanceof Player;