proper unregistering of deactivated plugins
This commit is contained in:
parent
2befc24d17
commit
cf78a2a141
@ -5,6 +5,8 @@ namespace ManiaControl\Plugins;
|
||||
use ManiaControl\Callbacks\CallbackListener;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
||||
use ManiaControl\Callbacks\TimerListener;
|
||||
use ManiaControl\Commands\CommandListener;
|
||||
|
||||
/**
|
||||
* Class managing Plugins
|
||||
@ -135,12 +137,15 @@ class PluginManager {
|
||||
return false;
|
||||
}
|
||||
$plugin = new $pluginClass();
|
||||
/** @var Plugin $plugin */
|
||||
/**
|
||||
* @var Plugin $plugin
|
||||
*/
|
||||
$this->activePlugins[$pluginClass] = $plugin;
|
||||
$this->savePluginStatus($pluginClass, true);
|
||||
try {
|
||||
$plugin->load($this->maniaControl);
|
||||
} catch(\Exception $e) {
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
$this->maniaControl->chat->sendError('Error while plugin activating ' . $pluginClass . ': ' . $e->getMessage(), $adminLogin);
|
||||
$this->maniaControl->log('Error while plugin activation: ' . $pluginClass . ': ' . $e->getMessage());
|
||||
unset($this->activePlugins[$pluginClass]);
|
||||
@ -164,16 +169,24 @@ class PluginManager {
|
||||
return false;
|
||||
}
|
||||
$plugin = $this->activePlugins[$pluginClass];
|
||||
/** @var Plugin $plugin */
|
||||
unset($this->activePlugins[$pluginClass]);
|
||||
/**
|
||||
* @var Plugin $plugin
|
||||
*/
|
||||
$plugin->unload();
|
||||
unset($this->activePlugins[$pluginClass]);
|
||||
if ($plugin instanceof CallbackListener) {
|
||||
$this->maniaControl->callbackManager->unregisterCallbackListener($plugin);
|
||||
$this->maniaControl->callbackManager->unregisterScriptCallbackListener($plugin);
|
||||
}
|
||||
if ($plugin instanceof CommandListener) {
|
||||
$this->maniaControl->commandManager->unregisterCommandListener($plugin);
|
||||
}
|
||||
if ($plugin instanceof ManialinkPageAnswerListener) {
|
||||
$this->maniaControl->manialinkManager->unregisterManialinkPageAnswerListener($plugin);
|
||||
}
|
||||
if ($plugin instanceof TimerListener) {
|
||||
$this->maniaControl->timerManager->unregisterTimerListenings($plugin);
|
||||
}
|
||||
$this->savePluginStatus($pluginClass, false);
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user