mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-27 05:40:01 +00:00
Added AsyncTasks timings
This commit is contained in:
parent
529f9b148b
commit
d4cae729c3
@ -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)
|
||||
]);
|
||||
|
@ -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");
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user