summaryrefslogtreecommitdiffstats
path: root/src/Bindings/PluginLua.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2016-06-12 18:11:40 +0200
committerMattes D <github@xoft.cz>2016-06-27 20:51:52 +0200
commit257c5a1a54396a3610f63bf469d6cf50ec76aef5 (patch)
treef4609bd58206783c9809455f5567cc4aa2ef512d /src/Bindings/PluginLua.cpp
parentLuaState: Implemented proper locking for cCallback. (diff)
downloadcuberite-257c5a1a54396a3610f63bf469d6cf50ec76aef5.tar
cuberite-257c5a1a54396a3610f63bf469d6cf50ec76aef5.tar.gz
cuberite-257c5a1a54396a3610f63bf469d6cf50ec76aef5.tar.bz2
cuberite-257c5a1a54396a3610f63bf469d6cf50ec76aef5.tar.lz
cuberite-257c5a1a54396a3610f63bf469d6cf50ec76aef5.tar.xz
cuberite-257c5a1a54396a3610f63bf469d6cf50ec76aef5.tar.zst
cuberite-257c5a1a54396a3610f63bf469d6cf50ec76aef5.zip
Diffstat (limited to 'src/Bindings/PluginLua.cpp')
-rw-r--r--src/Bindings/PluginLua.cpp109
1 files changed, 1 insertions, 108 deletions
diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp
index 04ea76f0a..ee0d289a1 100644
--- a/src/Bindings/PluginLua.cpp
+++ b/src/Bindings/PluginLua.cpp
@@ -62,9 +62,7 @@ void cPluginLua::Close(void)
return;
}
- // Remove the command bindings and web tabs:
- ClearCommands();
- ClearConsoleCommands();
+ // Remove the web tabs:
ClearWebTabs();
// Release all the references in the hook map:
@@ -994,91 +992,6 @@ bool cPluginLua::OnWorldTick(cWorld & a_World, std::chrono::milliseconds a_Dt, s
-bool cPluginLua::HandleCommand(const AStringVector & a_Split, cPlayer & a_Player, const AString & a_FullCommand)
-{
- ASSERT(!a_Split.empty());
- cOperation op(*this);
- CommandMap::iterator cmd = m_Commands.find(a_Split[0]);
- if (cmd == m_Commands.end())
- {
- LOGWARNING("Command handler is registered in cPluginManager but not in cPlugin, wtf? Command \"%s\".", a_Split[0].c_str());
- return false;
- }
-
- bool res = false;
- op().Call(cmd->second, a_Split, &a_Player, a_FullCommand, cLuaState::Return, res);
- return res;
-}
-
-
-
-
-
-bool cPluginLua::HandleConsoleCommand(const AStringVector & a_Split, cCommandOutputCallback & a_Output, const AString & a_FullCommand)
-{
- ASSERT(!a_Split.empty());
- cOperation op(*this);
- CommandMap::iterator cmd = m_ConsoleCommands.find(a_Split[0]);
- if (cmd == m_ConsoleCommands.end())
- {
- LOGWARNING("Console command handler is registered in cPluginManager but not in cPlugin, wtf? Console command \"%s\", plugin \"%s\".",
- a_Split[0].c_str(), GetName().c_str()
- );
- return false;
- }
-
- bool res = false;
- AString str;
- op().Call(cmd->second, a_Split, a_FullCommand, cLuaState::Return, res, str);
- if (res && !str.empty())
- {
- a_Output.Out(str);
- }
- return res;
-}
-
-
-
-
-
-void cPluginLua::ClearCommands(void)
-{
- cOperation op(*this);
-
- // Unreference the bound functions so that Lua can GC them
- if (m_LuaState != nullptr)
- {
- for (CommandMap::iterator itr = m_Commands.begin(), end = m_Commands.end(); itr != end; ++itr)
- {
- luaL_unref(m_LuaState, LUA_REGISTRYINDEX, itr->second);
- }
- }
- m_Commands.clear();
-}
-
-
-
-
-
-void cPluginLua::ClearConsoleCommands(void)
-{
- cOperation op(*this);
-
- // Unreference the bound functions so that Lua can GC them
- if (m_LuaState != nullptr)
- {
- for (CommandMap::iterator itr = m_ConsoleCommands.begin(), end = m_ConsoleCommands.end(); itr != end; ++itr)
- {
- luaL_unref(m_LuaState, LUA_REGISTRYINDEX, itr->second);
- }
- }
- m_ConsoleCommands.clear();
-}
-
-
-
-
-
bool cPluginLua::CanAddOldStyleHook(int a_HookType)
{
const char * FnName = GetHookFnName(a_HookType);
@@ -1227,26 +1140,6 @@ int cPluginLua::CallFunctionFromForeignState(
-void cPluginLua::BindCommand(const AString & a_Command, int a_FnRef)
-{
- ASSERT(m_Commands.find(a_Command) == m_Commands.end());
- m_Commands[a_Command] = a_FnRef;
-}
-
-
-
-
-
-void cPluginLua::BindConsoleCommand(const AString & a_Command, int a_FnRef)
-{
- ASSERT(m_ConsoleCommands.find(a_Command) == m_ConsoleCommands.end());
- m_ConsoleCommands[a_Command] = a_FnRef;
-}
-
-
-
-
-
bool cPluginLua::CallbackWindowClosing(int a_FnRef, cWindow & a_Window, cPlayer & a_Player, bool a_CanRefuse)
{
ASSERT(a_FnRef != LUA_REFNIL);