summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Pioch <lukas@zgow.de>2014-11-02 21:01:23 +0100
committerLukas Pioch <lukas@zgow.de>2014-11-02 21:01:23 +0100
commit9f71a4e7aec04c4c7fa57ac4b82f27a21044f798 (patch)
tree25761b6d78453e356cab4debd1db8348e50c0a7c
parentMerge pull request #1569 from mc-server/GrownBiomes (diff)
downloadcuberite-9f71a4e7aec04c4c7fa57ac4b82f27a21044f798.tar
cuberite-9f71a4e7aec04c4c7fa57ac4b82f27a21044f798.tar.gz
cuberite-9f71a4e7aec04c4c7fa57ac4b82f27a21044f798.tar.bz2
cuberite-9f71a4e7aec04c4c7fa57ac4b82f27a21044f798.tar.lz
cuberite-9f71a4e7aec04c4c7fa57ac4b82f27a21044f798.tar.xz
cuberite-9f71a4e7aec04c4c7fa57ac4b82f27a21044f798.tar.zst
cuberite-9f71a4e7aec04c4c7fa57ac4b82f27a21044f798.zip
-rw-r--r--src/Bindings/ManualBindings.cpp2
-rw-r--r--src/Root.cpp16
-rw-r--r--src/Root.h3
-rw-r--r--src/World.cpp22
-rw-r--r--src/World.h3
5 files changed, 46 insertions, 0 deletions
diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp
index a4a5d79b4..5343090d9 100644
--- a/src/Bindings/ManualBindings.cpp
+++ b/src/Bindings/ManualBindings.cpp
@@ -3368,6 +3368,7 @@ void ManualBindings::Bind(lua_State * tolua_S)
tolua_beginmodule(tolua_S, "cRoot");
tolua_function(tolua_S, "FindAndDoWithPlayer", tolua_DoWith <cRoot, cPlayer, &cRoot::FindAndDoWithPlayer>);
+ tolua_function(tolua_S, "FindAndDoWithUUID", tolua_DoWith <cRoot, cPlayer, &cRoot::FindAndDoWithUUID>);
tolua_function(tolua_S, "ForEachPlayer", tolua_ForEach<cRoot, cPlayer, &cRoot::ForEachPlayer>);
tolua_function(tolua_S, "ForEachWorld", tolua_ForEach<cRoot, cWorld, &cRoot::ForEachWorld>);
tolua_function(tolua_S, "GetFurnaceRecipe", tolua_cRoot_GetFurnaceRecipe);
@@ -3389,6 +3390,7 @@ void ManualBindings::Bind(lua_State * tolua_S)
tolua_function(tolua_S, "DoWithFlowerPotAt", tolua_DoWithXYZ<cWorld, cFlowerPotEntity, &cWorld::DoWithFlowerPotAt>);
tolua_function(tolua_S, "DoWithPlayer", tolua_DoWith< cWorld, cPlayer, &cWorld::DoWithPlayer>);
tolua_function(tolua_S, "FindAndDoWithPlayer", tolua_DoWith< cWorld, cPlayer, &cWorld::FindAndDoWithPlayer>);
+ tolua_function(tolua_S, "FindAndDoWithUUID", tolua_DoWith< cWorld, cPlayer, &cWorld::FindAndDoWithUUID>);
tolua_function(tolua_S, "ForEachBlockEntityInChunk", tolua_ForEachInChunk<cWorld, cBlockEntity, &cWorld::ForEachBlockEntityInChunk>);
tolua_function(tolua_S, "ForEachChestInChunk", tolua_ForEachInChunk<cWorld, cChestEntity, &cWorld::ForEachChestInChunk>);
tolua_function(tolua_S, "ForEachEntity", tolua_ForEach< cWorld, cEntity, &cWorld::ForEachEntity>);
diff --git a/src/Root.cpp b/src/Root.cpp
index 24c1a4cc8..539284665 100644
--- a/src/Root.cpp
+++ b/src/Root.cpp
@@ -633,6 +633,22 @@ bool cRoot::FindAndDoWithPlayer(const AString & a_PlayerName, cPlayerListCallbac
+bool cRoot::FindAndDoWithUUID(const AString & a_PlayerUUID, cPlayerListCallback & a_Callback)
+{
+ for (WorldMap::iterator itr = m_WorldsByName.begin(); itr != m_WorldsByName.end();itr++)
+ {
+ if (itr->second->FindAndDoWithUUID(a_PlayerUUID, a_Callback))
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+
+
+
+
AString cRoot::GetProtocolVersionTextFromInt(int a_ProtocolVersion)
{
return cProtocolRecognizer::GetVersionTextFromInt(a_ProtocolVersion);
diff --git a/src/Root.h b/src/Root.h
index 020a6cff0..456217140 100644
--- a/src/Root.h
+++ b/src/Root.h
@@ -125,6 +125,9 @@ public:
/// Finds a player from a partial or complete player name and calls the callback - case-insensitive
bool FindAndDoWithPlayer(const AString & a_PlayerName, cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS <<
+
+ /// Finds a player with the same uuid and call the callback */
+ bool FindAndDoWithUUID(const AString & a_PlayerUUID, cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS <<
// tolua_begin
diff --git a/src/World.cpp b/src/World.cpp
index 2e079d447..212566194 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -2729,6 +2729,28 @@ bool cWorld::FindAndDoWithPlayer(const AString & a_PlayerNameHint, cPlayerListCa
+bool cWorld::FindAndDoWithUUID(const AString & a_PlayerUUID, cPlayerListCallback & a_Callback)
+{
+ cPlayer * FoundPlayer = nullptr;
+ cCSLock Lock(m_CSPlayers);
+ for (cPlayerList::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
+ {
+ if ((*itr)->GetUUID() == a_PlayerUUID) { // Match found and exit
+ FoundPlayer = *itr;
+ break;
+ }
+ }
+ if (FoundPlayer != nullptr)
+ {
+ return a_Callback.Item (FoundPlayer);
+ }
+ return false;
+}
+
+
+
+
+
// TODO: This interface is dangerous!
cPlayer * cWorld::FindClosestPlayer(const Vector3d & a_Pos, float a_SightLimit, bool a_CheckLineOfSight)
{
diff --git a/src/World.h b/src/World.h
index ec6dcadde..aeb8abf81 100644
--- a/src/World.h
+++ b/src/World.h
@@ -323,6 +323,9 @@ public:
// TODO: This interface is dangerous - rewrite to DoWithClosestPlayer(pos, sight, action)
cPlayer * FindClosestPlayer(const Vector3d & a_Pos, float a_SightLimit, bool a_CheckLineOfSight = true);
+ /** Finds a player with the same uuid and call the callback */
+ bool FindAndDoWithUUID(const AString & a_PlayerUUID, cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS <<
+
void SendPlayerList(cPlayer * a_DestPlayer); // Sends playerlist to the player
/** Adds the entity into its appropriate chunk; takes ownership of the entity ptr.