DisablePluginException now can be used to disable plugins (#4780)

closes #2671
This commit is contained in:
Covered123
2022-05-20 13:01:34 -03:00
committed by GitHub
parent 6482aa7c64
commit 2b84cb7be4
2 changed files with 34 additions and 1 deletions

View File

@@ -444,7 +444,12 @@ class PluginManager{
$this->server->getLogger()->info($this->server->getLanguage()->translate(KnownTranslationFactory::pocketmine_plugin_enable($plugin->getDescription()->getFullName())));
$plugin->getScheduler()->setEnabled(true);
$plugin->onEnableStateChange(true);
try{
$plugin->onEnableStateChange(true);
}catch(DisablePluginException){
$this->disablePlugin($plugin);
}
if($plugin->isEnabled()){ //the plugin may have disabled itself during onEnable()
$this->enabledPlugins[$plugin->getDescription()->getName()] = $plugin;