Server: added getPlayerByUUID() and getPlayerByRawUUID()

closes #2047

Since the player list already indexes players by UUID, it's simple to just use that for fetching the player.

A possible future improvement could be to allow fetching an _offline_ player by UUID, but no capability to do that is yet available.
This commit is contained in:
Dylan K. Taylor 2018-03-01 09:09:34 +00:00
parent 28e601bbb9
commit 5a89e80873

View File

@ -878,6 +878,28 @@ class Server{
return $matchedPlayers;
}
/**
* Returns the player online with the specified raw UUID, or null if not found
*
* @param string $rawUUID
*
* @return null|Player
*/
public function getPlayerByRawUUID(string $rawUUID) : ?Player{
return $this->playerList[$rawUUID] ?? null;
}
/**
* Returns the player online with a UUID equivalent to the specified UUID object, or null if not found
*
* @param UUID $uuid
*
* @return null|Player
*/
public function getPlayerByUUID(UUID $uuid) : ?Player{
return $this->getPlayerByRawUUID($uuid->toBinary());
}
/**
* @return Level[]
*/