summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MCServer/Plugins/APIDump/APIDesc.lua3
-rw-r--r--src/ManualBindings.cpp29
2 files changed, 24 insertions, 8 deletions
diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua
index 6545c1f9f..a08f6f24b 100644
--- a/MCServer/Plugins/APIDump/APIDesc.lua
+++ b/MCServer/Plugins/APIDump/APIDesc.lua
@@ -1715,8 +1715,9 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage);
Get = { Params = "", Return = "cPluginManager", Notes = "Returns the single instance of the plugin manager" },
GetAllPlugins = { Params = "", Return = "table", Notes = "Returns a table (dictionary) of all plugins, [name => {{cPlugin}}] pairing." },
GetCommandPermission = { Params = "Command", Return = "Permission", Notes = "Returns the permission needed for executing the specified command" },
+ GetCurrentPlugin = { Params = "", Return = "{{cPlugin}}", Notes = "Returns the {{cPlugin}} object for the calling plugin. This is the same object that the Initialize function receives as the argument." },
GetNumPlugins = { Params = "", Return = "number", Notes = "Returns the number of plugins, including the disabled ones" },
- GetPlugin = { Params = "PluginName", Return = "{{cPlugin|cPlugin}}", Notes = "Returns a plugin handle of the specified plugin" },
+ GetPlugin = { Params = "PluginName", Return = "{{cPlugin}}", Notes = "Returns a plugin handle of the specified plugin" },
IsCommandBound = { Params = "Command", Return = "bool", Notes = "Returns true if in-game Command is already bound (by any plugin)" },
IsConsoleCommandBound = { Params = "Command", Return = "bool", Notes = "Returns true if console Command is already bound (by any plugin)" },
LoadPlugin = { Params = "PluginFolder", Return = "", Notes = "(<b>DEPRECATED</b>) Loads a plugin from the specified folder. NOTE: Loading plugins may be an unsafe operation and may result in a deadlock or a crash. This API is deprecated and might be removed." },
diff --git a/src/ManualBindings.cpp b/src/ManualBindings.cpp
index 02b3347f6..2483cbef0 100644
--- a/src/ManualBindings.cpp
+++ b/src/ManualBindings.cpp
@@ -985,28 +985,26 @@ static int tolua_cWorld_QueueTask(lua_State * tolua_S)
static int tolua_cPluginManager_GetAllPlugins(lua_State * tolua_S)
{
- cPluginManager* self = (cPluginManager*) tolua_tousertype(tolua_S,1,0);
+ cPluginManager * self = (cPluginManager *)tolua_tousertype(tolua_S, 1, 0);
const cPluginManager::PluginMap & AllPlugins = self->GetAllPlugins();
lua_newtable(tolua_S);
- //lua_createtable(tolua_S, AllPlugins.size(), 0);
int newTable = lua_gettop(tolua_S);
int index = 1;
cPluginManager::PluginMap::const_iterator iter = AllPlugins.begin();
- while(iter != AllPlugins.end())
+ while (iter != AllPlugins.end())
{
const cPlugin* Plugin = iter->second;
- tolua_pushstring( tolua_S, iter->first.c_str() );
- if( Plugin != NULL )
+ tolua_pushstring(tolua_S, iter->first.c_str());
+ if (Plugin != NULL)
{
- tolua_pushusertype( tolua_S, (void*)Plugin, "const cPlugin" );
+ tolua_pushusertype(tolua_S, (void *)Plugin, "const cPlugin");
}
else
{
tolua_pushboolean(tolua_S, 0);
}
- //lua_rawseti(tolua_S, newTable, index);
lua_rawset(tolua_S, -3);
++iter;
++index;
@@ -1018,6 +1016,22 @@ static int tolua_cPluginManager_GetAllPlugins(lua_State * tolua_S)
+static int tolua_cPluginManager_GetCurrentPlugin(lua_State * S)
+{
+ cPluginLua * Plugin = GetLuaPlugin(S);
+ if (Plugin == NULL)
+ {
+ // An error message has already been printed in GetLuaPlugin()
+ return 0;
+ }
+ tolua_pushusertype(S, Plugin, "cPluginLua");
+ return 1;
+}
+
+
+
+
+
static int tolua_cPluginManager_AddHook_FnRef(cPluginManager * a_PluginManager, cLuaState & S, int a_ParamIdx)
{
// Helper function for cPluginmanager:AddHook() binding
@@ -2231,6 +2245,7 @@ void ManualBindings::Bind(lua_State * tolua_S)
tolua_function(tolua_S, "ForEachCommand", tolua_cPluginManager_ForEachCommand);
tolua_function(tolua_S, "ForEachConsoleCommand", tolua_cPluginManager_ForEachConsoleCommand);
tolua_function(tolua_S, "GetAllPlugins", tolua_cPluginManager_GetAllPlugins);
+ tolua_function(tolua_S, "GetCurrentPlugin", tolua_cPluginManager_GetCurrentPlugin);
tolua_endmodule(tolua_S);
tolua_beginmodule(tolua_S, "cPlayer");