diff options
author | Mattes D <github@xoft.cz> | 2013-11-05 22:24:23 +0100 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2013-11-05 22:24:23 +0100 |
commit | 12eeb3f6c88f54b77363923fcff2bd4ce53ff07f (patch) | |
tree | 3ed83d1132a2b1a8b6f9e36a7d6f3a527d258992 /source/PluginManager.cpp | |
parent | Clarified cBlockHandler::ConvertToPickups() dox. (diff) | |
parent | Implemented suggestions (diff) | |
download | cuberite-12eeb3f6c88f54b77363923fcff2bd4ce53ff07f.tar cuberite-12eeb3f6c88f54b77363923fcff2bd4ce53ff07f.tar.gz cuberite-12eeb3f6c88f54b77363923fcff2bd4ce53ff07f.tar.bz2 cuberite-12eeb3f6c88f54b77363923fcff2bd4ce53ff07f.tar.lz cuberite-12eeb3f6c88f54b77363923fcff2bd4ce53ff07f.tar.xz cuberite-12eeb3f6c88f54b77363923fcff2bd4ce53ff07f.tar.zst cuberite-12eeb3f6c88f54b77363923fcff2bd4ce53ff07f.zip |
Diffstat (limited to 'source/PluginManager.cpp')
-rw-r--r-- | source/PluginManager.cpp | 52 |
1 files changed, 37 insertions, 15 deletions
diff --git a/source/PluginManager.cpp b/source/PluginManager.cpp index 5ae70d48d..3ac2366ca 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,21 @@ 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."); + InsertDefaultPlugins(a_SettingsIni); } - - 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 +143,7 @@ void cPluginManager::ReloadPluginsNow(void) { LOG("-- No Plugins Loaded --"); } - else if ((GetNumPlugins() > 1) || (GetNumPlugins() == 0)) + else if (GetNumPlugins() > 1) { LOG("-- Loaded %i Plugins --", GetNumPlugins()); } @@ -151,6 +157,22 @@ void cPluginManager::ReloadPluginsNow(void) +void cPluginManager::InsertDefaultPlugins(cIniFile & a_SettingsIni) +{ + a_SettingsIni.AddKeyName("Plugins"); + a_SettingsIni.AddKeyComment("Plugins", " Plugin=Debuggers"); + a_SettingsIni.AddKeyComment("Plugins", " Plugin=HookNotify"); + a_SettingsIni.AddKeyComment("Plugins", " Plugin=ChunkWorx"); + a_SettingsIni.AddKeyComment("Plugins", " Plugin=APIDump"); + a_SettingsIni.SetValue("Plugins", "Plugin", "Core"); + a_SettingsIni.SetValue("Plugins", "Plugin", "TransAPI"); + a_SettingsIni.SetValue("Plugins", "Plugin", "ChatLog"); +} + + + + + void cPluginManager::Tick(float a_Dt) { while (!m_DisablePluginList.empty()) |