summaryrefslogtreecommitdiffstats
path: root/src/Bindings/PluginManager.cpp
diff options
context:
space:
mode:
authortycho <work.tycho@gmail.com>2015-05-19 12:55:23 +0200
committertycho <work.tycho@gmail.com>2015-05-19 12:55:23 +0200
commit95e06ab93ff98c7bcffcf8a68a479802c8a56fe3 (patch)
tree87e8224964c12b746e34701dfffbcd3201889cdf /src/Bindings/PluginManager.cpp
parentFixed a lot of warnings (diff)
parentMerge pull request #2019 from mc-server/OverrideArgs (diff)
downloadcuberite-95e06ab93ff98c7bcffcf8a68a479802c8a56fe3.tar
cuberite-95e06ab93ff98c7bcffcf8a68a479802c8a56fe3.tar.gz
cuberite-95e06ab93ff98c7bcffcf8a68a479802c8a56fe3.tar.bz2
cuberite-95e06ab93ff98c7bcffcf8a68a479802c8a56fe3.tar.lz
cuberite-95e06ab93ff98c7bcffcf8a68a479802c8a56fe3.tar.xz
cuberite-95e06ab93ff98c7bcffcf8a68a479802c8a56fe3.tar.zst
cuberite-95e06ab93ff98c7bcffcf8a68a479802c8a56fe3.zip
Diffstat (limited to 'src/Bindings/PluginManager.cpp')
-rw-r--r--src/Bindings/PluginManager.cpp74
1 files changed, 54 insertions, 20 deletions
diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp
index db2493955..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");
}
@@ -525,6 +525,42 @@ bool cPluginManager::CallHookEntityTeleport(cEntity & a_Entity, const Vector3d &
+bool cPluginManager::CallHookEntityChangeWorld(cEntity & a_Entity, cWorld & a_World)
+{
+ FIND_HOOK(HOOK_ENTITY_CHANGE_WORLD);
+ VERIFY_HOOK;
+
+ for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
+ {
+ if ((*itr)->OnEntityChangeWorld(a_Entity, a_World))
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+
+
+
+bool cPluginManager::CallHookEntityChangedWorld(cEntity & a_Entity, cWorld & a_World)
+{
+ FIND_HOOK(HOOK_ENTITY_CHANGED_WORLD);
+ VERIFY_HOOK;
+
+ for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
+ {
+ if ((*itr)->OnEntityChangedWorld(a_Entity, a_World))
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+
+
+
bool cPluginManager::CallHookExecuteCommand(cPlayer * a_Player, const AStringVector & a_Split, const AString & a_EntireCommand, CommandResult & a_Result)
{
FIND_HOOK(HOOK_EXECUTE_COMMAND);
@@ -1896,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);