summaryrefslogtreecommitdiffstats
path: root/src/Bindings
diff options
context:
space:
mode:
authortycho <tycho@localhost>2015-05-14 16:47:51 +0200
committertycho <work.tycho@gmail.com>2015-05-16 11:46:51 +0200
commitb9efa02c80b54e044326771bbffdddf206daef2e (patch)
treeab615f16b3c46b107f1df0e180c835300dbd19b7 /src/Bindings
parentAdded TCLAP (diff)
downloadcuberite-b9efa02c80b54e044326771bbffdddf206daef2e.tar
cuberite-b9efa02c80b54e044326771bbffdddf206daef2e.tar.gz
cuberite-b9efa02c80b54e044326771bbffdddf206daef2e.tar.bz2
cuberite-b9efa02c80b54e044326771bbffdddf206daef2e.tar.lz
cuberite-b9efa02c80b54e044326771bbffdddf206daef2e.tar.xz
cuberite-b9efa02c80b54e044326771bbffdddf206daef2e.tar.zst
cuberite-b9efa02c80b54e044326771bbffdddf206daef2e.zip
Diffstat (limited to 'src/Bindings')
-rw-r--r--src/Bindings/PluginManager.cpp38
-rw-r--r--src/Bindings/PluginManager.h11
2 files changed, 24 insertions, 25 deletions
diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp
index db2493955..86be30938 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");
}
@@ -1896,25 +1896,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 d8c886b62..faabf3aec 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;
@@ -364,20 +365,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