summaryrefslogtreecommitdiffstats
path: root/source/PluginManager.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2013-11-04 22:51:24 +0100
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2013-11-04 22:51:24 +0100
commite832736e0bf315585f873b43520d1d771930a1c2 (patch)
treed9fce26b198075371b04356b6f66f31da51f4493 /source/PluginManager.cpp
parentProtocol 1.7: Added more client-bound packets. (diff)
downloadcuberite-e832736e0bf315585f873b43520d1d771930a1c2.tar
cuberite-e832736e0bf315585f873b43520d1d771930a1c2.tar.gz
cuberite-e832736e0bf315585f873b43520d1d771930a1c2.tar.bz2
cuberite-e832736e0bf315585f873b43520d1d771930a1c2.tar.lz
cuberite-e832736e0bf315585f873b43520d1d771930a1c2.tar.xz
cuberite-e832736e0bf315585f873b43520d1d771930a1c2.tar.zst
cuberite-e832736e0bf315585f873b43520d1d771930a1c2.zip
Diffstat (limited to '')
-rw-r--r--source/PluginManager.cpp37
1 files changed, 22 insertions, 15 deletions
diff --git a/source/PluginManager.cpp b/source/PluginManager.cpp
index 5ae70d48d..ac79942b7 100644
--- a/source/PluginManager.cpp
+++ b/source/PluginManager.cpp
@@ -95,6 +95,17 @@ void cPluginManager::FindPlugins(void)
void cPluginManager::ReloadPluginsNow(void)
{
+ cIniFile a_SettingsIni;
+ a_SettingsIni.ReadFile("settings.ini");
+ ReloadPluginsNow(a_SettingsIni);
+}
+
+
+
+
+
+void cPluginManager::ReloadPluginsNow(cIniFile & a_SettingsIni)
+{
LOG("-- Loading Plugins --");
m_bReloadPlugins = false;
UnloadPluginsNow();
@@ -102,26 +113,22 @@ void cPluginManager::ReloadPluginsNow(void)
FindPlugins();
cServer::BindBuiltInConsoleCommands();
-
- cIniFile IniFile;
- if (!IniFile.ReadFile("settings.ini"))
+
+ unsigned int KeyNum = a_SettingsIni.FindKey("Plugins");
+ unsigned int NumPlugins = ((KeyNum != -1) ? (a_SettingsIni.GetNumValues(KeyNum)) : 0);
+ if (KeyNum == -1)
{
- LOGWARNING("cPluginManager: Can't find settings.ini, so can't load any plugins.");
+ a_SettingsIni.AddKeyName("Plugins");
+ a_SettingsIni.AddKeyComment("Plugins", " Plugin=Core");
}
-
- unsigned int KeyNum = IniFile.FindKey("Plugins");
- unsigned int NumPlugins = IniFile.GetNumValues(KeyNum);
- if (NumPlugins > 0)
+ else if (NumPlugins > 0)
{
for(unsigned int i = 0; i < NumPlugins; i++)
{
- AString ValueName = IniFile.GetValueName(KeyNum, i );
- if (
- (ValueName.compare("NewPlugin") == 0) ||
- (ValueName.compare("Plugin") == 0)
- )
+ AString ValueName = a_SettingsIni.GetValueName(KeyNum, i);
+ if (ValueName.compare("Plugin") == 0)
{
- AString PluginFile = IniFile.GetValue(KeyNum, i);
+ AString PluginFile = a_SettingsIni.GetValue(KeyNum, i);
if (!PluginFile.empty())
{
if (m_Plugins.find(PluginFile) != m_Plugins.end())
@@ -137,7 +144,7 @@ void cPluginManager::ReloadPluginsNow(void)
{
LOG("-- No Plugins Loaded --");
}
- else if ((GetNumPlugins() > 1) || (GetNumPlugins() == 0))
+ else if (GetNumPlugins() > 1)
{
LOG("-- Loaded %i Plugins --", GetNumPlugins());
}