mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-18 09:24:05 +00:00
Merge branch 'release/3.2' into release/3.3
This commit is contained in:
commit
2d88058710
@ -23,6 +23,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\scheduler;
|
namespace pocketmine\scheduler;
|
||||||
|
|
||||||
|
use pocketmine\utils\Utils;
|
||||||
|
|
||||||
abstract class Task{
|
abstract class Task{
|
||||||
|
|
||||||
/** @var TaskHandler */
|
/** @var TaskHandler */
|
||||||
@ -46,6 +48,10 @@ abstract class Task{
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getName() : string{
|
||||||
|
return Utils::getNiceClassName($this);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param TaskHandler|null $taskHandler
|
* @param TaskHandler|null $taskHandler
|
||||||
*/
|
*/
|
||||||
|
@ -66,7 +66,7 @@ class TaskHandler{
|
|||||||
$this->taskId = $taskId;
|
$this->taskId = $taskId;
|
||||||
$this->delay = $delay;
|
$this->delay = $delay;
|
||||||
$this->period = $period;
|
$this->period = $period;
|
||||||
$this->taskName = get_class($task);
|
$this->taskName = $task->getName();
|
||||||
$this->ownerName = $ownerName ?? "Unknown";
|
$this->ownerName = $ownerName ?? "Unknown";
|
||||||
$this->timings = Timings::getScheduledTaskTimings($this, $period);
|
$this->timings = Timings::getScheduledTaskTimings($this, $period);
|
||||||
$this->task->setHandler($this);
|
$this->task->setHandler($this);
|
||||||
|
@ -52,6 +52,23 @@ class Utils{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a readable identifier for the class of the given object. Sanitizes class names for closures.
|
||||||
|
*
|
||||||
|
* @param object $obj
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @throws \ReflectionException
|
||||||
|
*/
|
||||||
|
public static function getNiceClassName(object $obj) : string{
|
||||||
|
$reflect = new \ReflectionClass($obj);
|
||||||
|
if($reflect->isAnonymous()){
|
||||||
|
return "anonymous@" . self::cleanPath($reflect->getFileName()) . "#L" . $reflect->getStartLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $reflect->getName();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets this machine / server instance unique ID
|
* Gets this machine / server instance unique ID
|
||||||
* Returns a hash, the first 32 characters (or 16 if raw)
|
* Returns a hash, the first 32 characters (or 16 if raw)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user