diff options
author | Alexander Harkness <me@bearbin.net> | 2015-05-19 11:53:44 +0200 |
---|---|---|
committer | Alexander Harkness <me@bearbin.net> | 2015-05-19 11:53:44 +0200 |
commit | fff5efedc331922bd871eddef886a75177e67d9a (patch) | |
tree | ea38ffc8455c2179ad8a817c5c988d2b68be2051 /src/Bindings | |
parent | Removed tip4commit, it's not used anymore. (diff) | |
parent | Add support for setting ports through command line (diff) | |
download | cuberite-fff5efedc331922bd871eddef886a75177e67d9a.tar cuberite-fff5efedc331922bd871eddef886a75177e67d9a.tar.gz cuberite-fff5efedc331922bd871eddef886a75177e67d9a.tar.bz2 cuberite-fff5efedc331922bd871eddef886a75177e67d9a.tar.lz cuberite-fff5efedc331922bd871eddef886a75177e67d9a.tar.xz cuberite-fff5efedc331922bd871eddef886a75177e67d9a.tar.zst cuberite-fff5efedc331922bd871eddef886a75177e67d9a.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Bindings/PluginManager.cpp | 38 | ||||
-rw-r--r-- | src/Bindings/PluginManager.h | 11 |
2 files changed, 24 insertions, 25 deletions
diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index cc74c8372..6fb6ef4fa 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -118,7 +118,7 @@ void cPluginManager::ReloadPluginsNow(void) -void cPluginManager::ReloadPluginsNow(cIniFile & a_SettingsIni) +void cPluginManager::ReloadPluginsNow(cSettingsRepositoryInterface & a_Settings) { LOG("-- Loading Plugins --"); @@ -130,7 +130,7 @@ void cPluginManager::ReloadPluginsNow(cIniFile & a_SettingsIni) RefreshPluginList(); // Load the plugins: - AStringVector ToLoad = GetFoldersToLoad(a_SettingsIni); + AStringVector ToLoad = GetFoldersToLoad(a_Settings); for (auto & pluginFolder: ToLoad) { LoadPlugin(pluginFolder); @@ -157,16 +157,16 @@ void cPluginManager::ReloadPluginsNow(cIniFile & a_SettingsIni) -void cPluginManager::InsertDefaultPlugins(cIniFile & a_SettingsIni) +void cPluginManager::InsertDefaultPlugins(cSettingsRepositoryInterface & a_Settings) { - 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.AddValue("Plugins", "Plugin", "Core"); - a_SettingsIni.AddValue("Plugins", "Plugin", "TransAPI"); - a_SettingsIni.AddValue("Plugins", "Plugin", "ChatLog"); + a_Settings.AddKeyName("Plugins"); + a_Settings.AddKeyComment("Plugins", " Plugin=Debuggers"); + a_Settings.AddKeyComment("Plugins", " Plugin=HookNotify"); + a_Settings.AddKeyComment("Plugins", " Plugin=ChunkWorx"); + a_Settings.AddKeyComment("Plugins", " Plugin=APIDump"); + a_Settings.AddValue("Plugins", "Plugin", "Core"); + a_Settings.AddValue("Plugins", "Plugin", "TransAPI"); + a_Settings.AddValue("Plugins", "Plugin", "ChatLog"); } @@ -1932,25 +1932,23 @@ size_t cPluginManager::GetNumLoadedPlugins(void) const -AStringVector cPluginManager::GetFoldersToLoad(cIniFile & a_SettingsIni) +AStringVector cPluginManager::GetFoldersToLoad(cSettingsRepositoryInterface & a_Settings) { // Check if the Plugins section exists. - int KeyNum = a_SettingsIni.FindKey("Plugins"); - if (KeyNum == -1) + if (a_Settings.KeyExists("Plugins")) { - InsertDefaultPlugins(a_SettingsIni); - KeyNum = a_SettingsIni.FindKey("Plugins"); + InsertDefaultPlugins(a_Settings); } // Get the list of plugins to load: AStringVector res; - int NumPlugins = a_SettingsIni.GetNumValues(KeyNum); - for (int i = 0; i < NumPlugins; i++) + auto Values = a_Settings.GetValues("Plugins"); + for (auto NameValue : Values) { - AString ValueName = a_SettingsIni.GetValueName(KeyNum, i); + AString ValueName = NameValue.first; if (ValueName.compare("Plugin") == 0) { - AString PluginFile = a_SettingsIni.GetValue(KeyNum, i); + AString PluginFile = NameValue.second; if (!PluginFile.empty()) { res.push_back(PluginFile); diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h index 2c3eaa75f..e528c049f 100644 --- a/src/Bindings/PluginManager.h +++ b/src/Bindings/PluginManager.h @@ -24,6 +24,7 @@ class cPlayer; class cPlugin; class cProjectileEntity; class cWorld; +class cSettingsRepositoryInterface; struct TakeDamageInfo; typedef SharedPtr<cPlugin> cPluginPtr; @@ -368,20 +369,20 @@ private: /** Reloads all plugins, defaulting to settings.ini for settings location */ void ReloadPluginsNow(void); - /** Reloads all plugins with a cIniFile object expected to be initialised to settings.ini */ - void ReloadPluginsNow(cIniFile & a_SettingsIni); + /** Reloads all plugins with a settings repo expected to be initialised to settings.ini */ + void ReloadPluginsNow(cSettingsRepositoryInterface & a_Settings); /** Unloads all plugins */ void UnloadPluginsNow(void); - /** Handles writing default plugins if 'Plugins' key not found using a cIniFile object expected to be intialised to settings.ini */ - void InsertDefaultPlugins(cIniFile & a_SettingsIni); + /** Handles writing default plugins if 'Plugins' key not found using a settings repo expected to be intialised to settings.ini */ + void InsertDefaultPlugins(cSettingsRepositoryInterface & a_Settings); /** Tries to match a_Command to the internal table of commands, if a match is found, the corresponding plugin is called. Returns crExecuted if the command is executed. */ CommandResult HandleCommand(cPlayer & a_Player, const AString & a_Command, bool a_ShouldCheckPermissions); /** Returns the folders that are specified in the settings ini to load plugins from. */ - AStringVector GetFoldersToLoad(cIniFile & a_SettingsIni); + AStringVector GetFoldersToLoad(cSettingsRepositoryInterface & a_Settings); } ; // tolua_export |