mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-03 08:39:53 +00:00
Fixed plugin schedulers crashing after disable/reenable
This commit is contained in:
parent
05ef13b23a
commit
15270f8329
@ -575,6 +575,7 @@ class PluginManager{
|
|||||||
foreach($plugin->getDescription()->getPermissions() as $perm){
|
foreach($plugin->getDescription()->getPermissions() as $perm){
|
||||||
$this->addPermission($perm);
|
$this->addPermission($perm);
|
||||||
}
|
}
|
||||||
|
$plugin->getScheduler()->setEnabled(true);
|
||||||
$plugin->getPluginLoader()->enablePlugin($plugin);
|
$plugin->getPluginLoader()->enablePlugin($plugin);
|
||||||
}catch(\Throwable $e){
|
}catch(\Throwable $e){
|
||||||
$this->server->getLogger()->logException($e);
|
$this->server->getLogger()->logException($e);
|
||||||
|
@ -36,7 +36,7 @@ class TaskScheduler{
|
|||||||
private $owner;
|
private $owner;
|
||||||
|
|
||||||
/** @var bool */
|
/** @var bool */
|
||||||
private $shutdown = false;
|
private $enabled = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var ReversePriorityQueue<Task>
|
* @var ReversePriorityQueue<Task>
|
||||||
@ -146,7 +146,7 @@ class TaskScheduler{
|
|||||||
* @throws \InvalidStateException
|
* @throws \InvalidStateException
|
||||||
*/
|
*/
|
||||||
private function addTask(Task $task, int $delay, int $period){
|
private function addTask(Task $task, int $delay, int $period){
|
||||||
if($this->shutdown){
|
if(!$this->enabled){
|
||||||
throw new \InvalidStateException("Tried to schedule task after scheduler shutdown");
|
throw new \InvalidStateException("Tried to schedule task after scheduler shutdown");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,10 +178,14 @@ class TaskScheduler{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function shutdown() : void{
|
public function shutdown() : void{
|
||||||
$this->shutdown = true;
|
$this->enabled = false;
|
||||||
$this->cancelAllTasks();
|
$this->cancelAllTasks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setEnabled(bool $enabled) : void{
|
||||||
|
$this->enabled = $enabled;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $currentTick
|
* @param int $currentTick
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user