PluginManager: fixed updating disabled scheduler when plugins cause other plugins to be disabled from within scheduled tasks

This commit is contained in:
Dylan K. Taylor 2022-04-10 21:00:16 +01:00
parent d1dfbd95e2
commit 2efce35331
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -471,8 +471,12 @@ class PluginManager{
}
public function tickSchedulers(int $currentTick) : void{
foreach($this->enabledPlugins as $p){
$p->getScheduler()->mainThreadHeartbeat($currentTick);
foreach($this->enabledPlugins as $pluginName => $p){
if(isset($this->enabledPlugins[$pluginName])){
//the plugin may have been disabled as a result of updating other plugins' schedulers, and therefore
//removed from enabledPlugins; however, foreach will still see it due to copy-on-write
$p->getScheduler()->mainThreadHeartbeat($currentTick);
}
}
}