diff options
author | tycho <work.tycho@gmail.com> | 2015-05-19 12:55:23 +0200 |
---|---|---|
committer | tycho <work.tycho@gmail.com> | 2015-05-19 12:55:23 +0200 |
commit | 95e06ab93ff98c7bcffcf8a68a479802c8a56fe3 (patch) | |
tree | 87e8224964c12b746e34701dfffbcd3201889cdf /src/Bindings/PluginLua.cpp | |
parent | Fixed a lot of warnings (diff) | |
parent | Merge pull request #2019 from mc-server/OverrideArgs (diff) | |
download | cuberite-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/PluginLua.cpp')
-rw-r--r-- | src/Bindings/PluginLua.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp index 76d3557a4..a8be26f71 100644 --- a/src/Bindings/PluginLua.cpp +++ b/src/Bindings/PluginLua.cpp @@ -534,6 +534,54 @@ bool cPluginLua::OnEntityAddEffect(cEntity & a_Entity, int a_EffectType, int a_E +bool cPluginLua::OnEntityChangeWorld(cEntity & a_Entity, cWorld & a_World) +{ + cCSLock Lock(m_CriticalSection); + if (!m_LuaState.IsValid()) + { + return false; + } + bool res = false; + cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_ENTITY_CHANGE_WORLD]; + for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) + { + m_LuaState.Call((int)(**itr), &a_Entity, &a_World, cLuaState::Return, res); + if (res) + { + return true; + } + } + return false; +} + + + + + +bool cPluginLua::OnEntityChangedWorld(cEntity & a_Entity, cWorld & a_World) +{ + cCSLock Lock(m_CriticalSection); + if (!m_LuaState.IsValid()) + { + return false; + } + bool res = false; + cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_ENTITY_CHANGED_WORLD]; + for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) + { + m_LuaState.Call((int)(**itr), &a_Entity, &a_World, res); + if (res) + { + return true; + } + } + return false; +} + + + + + bool cPluginLua::OnExecuteCommand(cPlayer * a_Player, const AStringVector & a_Split, const AString & a_EntireCommand, cPluginManager::CommandResult & a_Result) { cCSLock Lock(m_CriticalSection); @@ -1884,6 +1932,8 @@ const char * cPluginLua::GetHookFnName(int a_HookType) case cPluginManager::HOOK_DISCONNECT: return "OnDisconnect"; case cPluginManager::HOOK_PLAYER_ANIMATION: return "OnPlayerAnimation"; case cPluginManager::HOOK_ENTITY_ADD_EFFECT: return "OnEntityAddEffect"; + case cPluginManager::HOOK_ENTITY_CHANGE_WORLD: return "OnEntityChangeWorld"; + case cPluginManager::HOOK_ENTITY_CHANGED_WORLD: return "OnEntityChangedWorld"; case cPluginManager::HOOK_ENTITY_TELEPORT: return "OnEntityTeleport"; case cPluginManager::HOOK_EXECUTE_COMMAND: return "OnExecuteCommand"; case cPluginManager::HOOK_HANDSHAKE: return "OnHandshake"; |