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