Properly deal with anonymous tasks in timings

This commit is contained in:
Dylan K. Taylor
2018-10-31 18:51:30 +00:00
parent 31ceafa111
commit ab48d85c35
3 changed files with 24 additions and 1 deletions

View File

@ -23,6 +23,8 @@ declare(strict_types=1);
namespace pocketmine\scheduler;
use pocketmine\utils\Utils;
abstract class Task{
/** @var TaskHandler */
@ -46,6 +48,10 @@ abstract class Task{
return -1;
}
public function getName() : string{
return Utils::getNiceClassName($this);
}
/**
* @param TaskHandler|null $taskHandler
*/

View File

@ -66,7 +66,7 @@ class TaskHandler{
$this->taskId = $taskId;
$this->delay = $delay;
$this->period = $period;
$this->taskName = get_class($task);
$this->taskName = $task->getName();
$this->ownerName = $ownerName ?? "Unknown";
$this->timings = Timings::getScheduledTaskTimings($this, $period);
$this->task->setHandler($this);