summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2014-07-27 00:03:00 +0200
committerHowaner <franzi.moos@googlemail.com>2014-07-27 00:03:00 +0200
commitf79e68266426993af94f811afc8296e7b159462a (patch)
tree9ac563ae55031630792383a7d067881b3b1445a2 /src
parentMerge pull request #1232 from mc-server/splash-entity (diff)
downloadcuberite-f79e68266426993af94f811afc8296e7b159462a.tar
cuberite-f79e68266426993af94f811afc8296e7b159462a.tar.gz
cuberite-f79e68266426993af94f811afc8296e7b159462a.tar.bz2
cuberite-f79e68266426993af94f811afc8296e7b159462a.tar.lz
cuberite-f79e68266426993af94f811afc8296e7b159462a.tar.xz
cuberite-f79e68266426993af94f811afc8296e7b159462a.tar.zst
cuberite-f79e68266426993af94f811afc8296e7b159462a.zip
Diffstat (limited to '')
-rw-r--r--src/Bindings/PluginManager.cpp46
1 files changed, 30 insertions, 16 deletions
diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp
index 088b92a6d..1d97d1331 100644
--- a/src/Bindings/PluginManager.cpp
+++ b/src/Bindings/PluginManager.cpp
@@ -124,44 +124,58 @@ void cPluginManager::ReloadPluginsNow(cIniFile & a_SettingsIni)
// Check if the Plugins section exists.
int KeyNum = a_SettingsIni.FindKey("Plugins");
- // If it does, how many plugins are there?
- int NumPlugins = ((KeyNum != -1) ? (a_SettingsIni.GetNumValues(KeyNum)) : 0);
-
if (KeyNum == -1)
{
InsertDefaultPlugins(a_SettingsIni);
+ KeyNum = a_SettingsIni.FindKey("Plugins");
}
- else if (NumPlugins > 0)
+
+ // How many plugins are there?
+ int NumPlugins = a_SettingsIni.GetNumValues(KeyNum);
+
+ for (int i = 0; i < NumPlugins; i++)
{
- for (int i = 0; i < NumPlugins; i++)
+ AString ValueName = a_SettingsIni.GetValueName(KeyNum, i);
+ if (ValueName.compare("Plugin") == 0)
{
- AString ValueName = a_SettingsIni.GetValueName(KeyNum, i);
- if (ValueName.compare("Plugin") == 0)
+ AString PluginFile = a_SettingsIni.GetValue(KeyNum, i);
+ if (!PluginFile.empty())
{
- AString PluginFile = a_SettingsIni.GetValue(KeyNum, i);
- if (!PluginFile.empty())
+ if (m_Plugins.find(PluginFile) != m_Plugins.end())
{
- if (m_Plugins.find(PluginFile) != m_Plugins.end())
- {
- LoadPlugin(PluginFile);
- }
+ LoadPlugin(PluginFile);
}
}
}
}
+
+ // Remove invalid plugins from the PluginMap.
+ for (PluginMap::iterator itr = m_Plugins.begin(); itr != m_Plugins.end();)
+ {
+ if (itr->second == NULL)
+ {
+ PluginMap::iterator thiz = itr;
+ ++thiz;
+ m_Plugins.erase(itr);
+ itr = thiz;
+ continue;
+ }
+ ++itr;
+ }
+
size_t NumLoadedPlugins = GetNumPlugins();
if (NumLoadedPlugins == 0)
{
LOG("-- No Plugins Loaded --");
}
- else if (NumLoadedPlugins > 1)
+ else if (NumLoadedPlugins == 1)
{
- LOG("-- Loaded %i Plugins --", (int)NumLoadedPlugins);
+ LOG("-- Loaded 1 Plugin --");
}
else
{
- LOG("-- Loaded 1 Plugin --");
+ LOG("-- Loaded %i Plugins --", (int)NumLoadedPlugins);
}
CallHookPluginsLoaded();
}