diff options
author | Mattes D <github@xoft.cz> | 2015-04-19 17:20:15 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2015-04-19 17:20:15 +0200 |
commit | 4a946aa8c40b084dd36352e617b24407a2dd537b (patch) | |
tree | c7d3bd7870293e84885c9e36ce71a5c3132a4c9b /src/Bindings/PluginManager.cpp | |
parent | Refactored cWebPlugin for C++11 style and proper WebTab clearing. (diff) | |
download | cuberite-4a946aa8c40b084dd36352e617b24407a2dd537b.tar cuberite-4a946aa8c40b084dd36352e617b24407a2dd537b.tar.gz cuberite-4a946aa8c40b084dd36352e617b24407a2dd537b.tar.bz2 cuberite-4a946aa8c40b084dd36352e617b24407a2dd537b.tar.lz cuberite-4a946aa8c40b084dd36352e617b24407a2dd537b.tar.xz cuberite-4a946aa8c40b084dd36352e617b24407a2dd537b.tar.zst cuberite-4a946aa8c40b084dd36352e617b24407a2dd537b.zip |
Diffstat (limited to 'src/Bindings/PluginManager.cpp')
-rw-r--r-- | src/Bindings/PluginManager.cpp | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index 45a778eda..003996802 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -181,11 +181,29 @@ void cPluginManager::Tick(float a_Dt) cCSLock Lock(m_CSPluginsToUnload); std::swap(m_PluginsToUnload, PluginsToUnload); } - for (auto & plugin: m_Plugins) + for (auto & folder: PluginsToUnload) { - if (std::find(PluginsToUnload.cbegin(), PluginsToUnload.cend(), plugin->GetFolderName()) != PluginsToUnload.cend()) + bool HasUnloaded = false; + bool HasFound = false; + for (auto & plugin: m_Plugins) { - plugin->Unload(); + if (plugin->GetFolderName() == folder) + { + HasFound = true; + if (plugin->IsLoaded()) + { + plugin->Unload(); + HasUnloaded = true; + } + } + } + if (!HasFound) + { + LOG("Cannot unload plugin in folder \"%s\", there's no such plugin folder", folder.c_str()); + } + else if (!HasUnloaded) + { + LOG("Cannot unload plugin in folder \"%s\", it has not been loaded.", folder.c_str()); } } // for plugin - m_Plugins[] @@ -1510,7 +1528,7 @@ bool cPluginManager::LoadPlugin(const AString & a_FolderName) } // for plugin - m_Plugins[] // Plugin not found - LOGD("%s: Plugin folder %s not found in the list of plugins.", __FUNCTION__, a_FolderName.c_str()); + LOG("Cannot load plugin, folder \"%s\" not found.", a_FolderName.c_str()); return false; } @@ -1556,6 +1574,22 @@ void cPluginManager::RemovePluginCommands(cPlugin * a_Plugin) +bool cPluginManager::IsPluginLoaded(const AString & a_PluginName) +{ + for (auto & plugin: m_Plugins) + { + if (plugin->GetName() == a_PluginName) + { + return true; + } + } + return false; +} + + + + + bool cPluginManager::BindCommand(const AString & a_Command, cPlugin * a_Plugin, const AString & a_Permission, const AString & a_HelpString) { CommandMap::iterator cmd = m_Commands.find(a_Command); |