Merge pull request #1552 from SphinxC0re/master
Added error handling to load <plugin> command
This commit is contained in:
commit
bf8de85fd6
@ -1827,7 +1827,8 @@ bool cPluginManager::DoWithPlugin(const AString & a_PluginName, cPluginCallback
|
||||
|
||||
bool cPluginManager::AddPlugin(cPlugin * a_Plugin)
|
||||
{
|
||||
m_Plugins[a_Plugin->GetDirectory()] = a_Plugin;
|
||||
m_Plugins[a_Plugin->GetDirectory()] = a_Plugin;
|
||||
|
||||
if (a_Plugin->Initialize())
|
||||
{
|
||||
// Initialization OK
|
||||
|
@ -491,6 +491,17 @@ void cServer::ExecuteConsoleCommand(const AString & a_Cmd, cCommandOutputCallbac
|
||||
{
|
||||
if (split.size() > 1)
|
||||
{
|
||||
cPluginManager::PluginMap map = cPluginManager::Get()->GetAllPlugins();
|
||||
|
||||
for(auto plugin_entry : map)
|
||||
{
|
||||
if(plugin_entry.first == split[1])
|
||||
{
|
||||
a_Output.Out("Error! Plugin is already loaded!");
|
||||
a_Output.Finished();
|
||||
return;
|
||||
}
|
||||
}
|
||||
a_Output.Out(cPluginManager::Get()->LoadPlugin(split[1]) ? "Plugin loaded" : "Error occurred loading plugin");
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user