diff options
author | Alexander Harkness <me@bearbin.net> | 2015-05-19 10:24:50 +0200 |
---|---|---|
committer | Alexander Harkness <me@bearbin.net> | 2015-05-19 10:24:50 +0200 |
commit | b50135e78f9967772d585be5a62a4c282162220a (patch) | |
tree | 105a4ae13752f4cb8e87c36a5391f615217f2a7b /src/Entities/Player.cpp | |
parent | Merge branch 'master' of https://github.com/mc-server/MCServer (diff) | |
parent | Added OnEntityChangeWorld.lua and OnEntityChangedWorld.lua hooks to APIDump (diff) | |
download | cuberite-b50135e78f9967772d585be5a62a4c282162220a.tar cuberite-b50135e78f9967772d585be5a62a4c282162220a.tar.gz cuberite-b50135e78f9967772d585be5a62a4c282162220a.tar.bz2 cuberite-b50135e78f9967772d585be5a62a4c282162220a.tar.lz cuberite-b50135e78f9967772d585be5a62a4c282162220a.tar.xz cuberite-b50135e78f9967772d585be5a62a4c282162220a.tar.zst cuberite-b50135e78f9967772d585be5a62a4c282162220a.zip |
Diffstat (limited to 'src/Entities/Player.cpp')
-rw-r--r-- | src/Entities/Player.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 607a663de..01ad26297 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1606,6 +1606,12 @@ bool cPlayer::DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn) return false; } + if (cRoot::Get()->GetPluginManager()->CallHookEntityChangeWorld(*this, *a_World)) + { + // A Plugin doesn't allow the player to change the world + return false; + } + // Send the respawn packet: if (a_ShouldSendRespawn && (m_ClientHandle != nullptr)) { @@ -1621,6 +1627,7 @@ bool cPlayer::DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn) // Queue adding player to the new world, including all the necessary adjustments to the object a_World->AddPlayer(this); + cWorld * OldWorld = cRoot::Get()->GetWorld(GetWorld()->GetName()); // Required for the hook HOOK_ENTITY_CHANGED_WORLD SetWorld(a_World); // Chunks may be streamed before cWorld::AddPlayer() sets the world to the new value // Update the view distance. @@ -1635,6 +1642,9 @@ bool cPlayer::DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn) // Broadcast the player into the new world. a_World->BroadcastSpawnEntity(*this); + // Player changed the world, call the hook + cRoot::Get()->GetPluginManager()->CallHookEntityChangedWorld(*this, *OldWorld); + return true; } |