improved PluginManager

This commit is contained in:
kremsy 2017-05-22 22:01:23 +02:00
parent 988feea67d
commit d03f155415

View File

@ -170,6 +170,23 @@ class PluginManager {
$plugin = $this->activePlugins[$pluginClass];
unset($this->activePlugins[$pluginClass]);
if ($plugin) {
$this->unloadPlugin($plugin);
}
$this->savePluginStatus($pluginClass, false);
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_PLUGIN_UNLOADED, $pluginClass, $plugin);
return true;
}
/**
* Unload the Plugin and all its Features
*
* @param \ManiaControl\Plugins\Plugin $plugin
*/
private function unloadPlugin(Plugin $plugin) {
$plugin->unload();
if ($plugin instanceof EchoListener) {
@ -194,12 +211,6 @@ class PluginManager {
if ($plugin instanceof CommunicationListener) {
$this->maniaControl->getCommunicationManager()->unregisterCommunicationListener($plugin);
}
$this->savePluginStatus($pluginClass, false);
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_PLUGIN_UNLOADED, $pluginClass, $plugin);
return true;
}
/**
@ -431,6 +442,9 @@ class PluginManager {
try {
$plugin->load($this->maniaControl);
} catch (\Exception $e) {
//Unload the Plugin and all its features
$this->unloadPlugin($plugin);
$message = "Error during Plugin Activation of '{$pluginClass}': '{$e->getMessage()}'";
$this->maniaControl->getChat()->sendError($message, $adminLogin);
Logger::logError($message);