Added OnTeleportEntity hook for plugins.
Plugins may or may not allow teleport to the new position. Updated the HookNotify plugin with it.
This commit is contained in:
@@ -857,6 +857,26 @@ bool cPluginLua::OnPlayerMoving(cPlayer & a_Player, const Vector3d & a_OldPositi
|
||||
|
||||
|
||||
|
||||
bool cPluginLua::OnEntityTeleport(cEntity & a_Entity, const Vector3d & a_OldPosition, const Vector3d & a_NewPosition)
|
||||
{
|
||||
cCSLock Lock(m_CriticalSection);
|
||||
bool res = false;
|
||||
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_ENTITY_TELEPORT];
|
||||
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
|
||||
{
|
||||
m_LuaState.Call((int)(**itr), &a_Entity, a_OldPosition, a_NewPosition, cLuaState::Return, res);
|
||||
if (res)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool cPluginLua::OnPlayerPlacedBlock(cPlayer & a_Player, const sSetBlock & a_BlockChange)
|
||||
{
|
||||
cCSLock Lock(m_CriticalSection);
|
||||
@@ -1577,6 +1597,7 @@ 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_TELEPORT: return "OnEntityTeleport";
|
||||
case cPluginManager::HOOK_EXECUTE_COMMAND: return "OnExecuteCommand";
|
||||
case cPluginManager::HOOK_HANDSHAKE: return "OnHandshake";
|
||||
case cPluginManager::HOOK_KILLING: return "OnKilling";
|
||||
|
||||
Reference in New Issue
Block a user