diff --git a/src/pocketmine/entity/Human.php b/src/pocketmine/entity/Human.php index 1fc5bd2588..febd69b8d3 100644 --- a/src/pocketmine/entity/Human.php +++ b/src/pocketmine/entity/Human.php @@ -105,13 +105,15 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ $this->nameTag = $this->namedtag["NameTag"]; } - foreach($this->namedtag->Inventory as $item){ - if($item["Slot"] >= 0 and $item["Slot"] < 9){ //Hotbar - $this->inventory->setHotbarSlotIndex($item["Slot"], isset($item["TrueSlot"]) ? $item["TrueSlot"] : -1); - }elseif($item["Slot"] >= 100 and $item["Slot"] < 104){ //Armor - $this->inventory->setItem($this->inventory->getSize() + $item["Slot"] - 100, ItemItem::get($item["id"], $item["Damage"], $item["Count"])); - }else{ - $this->inventory->setItem($item["Slot"] - 9, ItemItem::get($item["id"], $item["Damage"], $item["Count"])); + if(isset($this->namedtag->Inventory) and $this->namedtag->Inventory instanceof Enum){ + foreach($this->namedtag->Inventory as $item){ + if($item["Slot"] >= 0 and $item["Slot"] < 9){ //Hotbar + $this->inventory->setHotbarSlotIndex($item["Slot"], isset($item["TrueSlot"]) ? $item["TrueSlot"] : -1); + }elseif($item["Slot"] >= 100 and $item["Slot"] < 104){ //Armor + $this->inventory->setItem($this->inventory->getSize() + $item["Slot"] - 100, ItemItem::get($item["id"], $item["Damage"], $item["Count"])); + }else{ + $this->inventory->setItem($item["Slot"] - 9, ItemItem::get($item["id"], $item["Damage"], $item["Count"])); + } } } @@ -194,7 +196,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ } - $this->namedtag->Skin = new Compound("Inventory", [ + $this->namedtag->Skin = new Compound("Skin", [ "Data" => new String("Data", $this->getSkinData()), "Slim" => new Byte("Slim", $this->isSkinSlim() ? 1 : 0) ]); diff --git a/src/pocketmine/event/Timings.php b/src/pocketmine/event/Timings.php index 3ac1f850bd..985eeabcf6 100644 --- a/src/pocketmine/event/Timings.php +++ b/src/pocketmine/event/Timings.php @@ -83,6 +83,8 @@ abstract class Timings{ public static $processQueueTimer; /** @var TimingsHandler */ public static $schedulerSyncTimer; + /** @var TimingsHandler */ + public static $schedulerAsyncTimer; /** @var TimingsHandler */ public static $playerCommandTimer; @@ -127,6 +129,7 @@ abstract class Timings{ self::$processQueueTimer = new TimingsHandler("processQueue"); self::$schedulerSyncTimer = new TimingsHandler("** Scheduler - Sync Tasks", PluginManager::$pluginParentTimer); + self::$schedulerAsyncTimer = new TimingsHandler("** Scheduler - Async Tasks"); self::$playerCommandTimer = new TimingsHandler("** playerCommand"); diff --git a/src/pocketmine/scheduler/AsyncPool.php b/src/pocketmine/scheduler/AsyncPool.php index 7be1af5d74..c91951a255 100644 --- a/src/pocketmine/scheduler/AsyncPool.php +++ b/src/pocketmine/scheduler/AsyncPool.php @@ -21,6 +21,7 @@ namespace pocketmine\scheduler; +use pocketmine\event\Timings; use pocketmine\Server; class AsyncPool{ @@ -113,6 +114,8 @@ class AsyncPool{ unset($this->taskWorkers[$task->getTaskId()]); $task->cleanObject(); + + unset($task); } public function removeTasks(){ @@ -129,6 +132,8 @@ class AsyncPool{ } public function collectTasks(){ + Timings::$schedulerAsyncTimer->startTiming(); + foreach($this->tasks as $task){ if($task->isGarbage()){ @@ -142,5 +147,7 @@ class AsyncPool{ $this->server->getLogger()->critical("On ".$info["scope"].", line ".$info["line"] .", ".$info["function"]."()"); } } + + Timings::$schedulerAsyncTimer->stopTiming(); } }