summaryrefslogtreecommitdiffstats
path: root/src/Protocol/MojangAPI.cpp
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-08-03 12:12:28 +0200
committermadmaxoft <github@xoft.cz>2014-08-03 22:04:50 +0200
commit003f18bd0f7593bddf5c6af89e3f6fc13632300d (patch)
treea485b0c959ec99cf9e956d9774f6a5b3aa10263f /src/Protocol/MojangAPI.cpp
parentToLua driver: disabled output buffering. (diff)
downloadcuberite-003f18bd0f7593bddf5c6af89e3f6fc13632300d.tar
cuberite-003f18bd0f7593bddf5c6af89e3f6fc13632300d.tar.gz
cuberite-003f18bd0f7593bddf5c6af89e3f6fc13632300d.tar.bz2
cuberite-003f18bd0f7593bddf5c6af89e3f6fc13632300d.tar.lz
cuberite-003f18bd0f7593bddf5c6af89e3f6fc13632300d.tar.xz
cuberite-003f18bd0f7593bddf5c6af89e3f6fc13632300d.tar.zst
cuberite-003f18bd0f7593bddf5c6af89e3f6fc13632300d.zip
Diffstat (limited to 'src/Protocol/MojangAPI.cpp')
-rw-r--r--src/Protocol/MojangAPI.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/Protocol/MojangAPI.cpp b/src/Protocol/MojangAPI.cpp
index 45baa5a4f..f53df1cba 100644
--- a/src/Protocol/MojangAPI.cpp
+++ b/src/Protocol/MojangAPI.cpp
@@ -129,6 +129,34 @@ void cMojangAPI::Start(cIniFile & a_SettingsIni)
+AString cMojangAPI::GetUUIDFromPlayerName(const AString & a_PlayerName, bool a_UseOnlyCached)
+{
+ // Convert the playername to lowercase:
+ AString lcPlayerName(a_PlayerName);
+ StrToLower(lcPlayerName);
+
+ // Request the cache to populate any names not yet contained:
+ if (!a_UseOnlyCached)
+ {
+ AStringVector PlayerNames;
+ PlayerNames.push_back(lcPlayerName);
+ CacheNamesToUUIDs(PlayerNames);
+ }
+
+ // Retrieve from cache:
+ cNameToUUIDMap::const_iterator itr = m_NameToUUID.find(lcPlayerName);
+ if (itr == m_NameToUUID.end())
+ {
+ // No UUID found
+ return "";
+ }
+ return itr->second.m_PlayerName;
+}
+
+
+
+
+
AStringVector cMojangAPI::GetUUIDsFromPlayerNames(const AStringVector & a_PlayerNames, bool a_UseOnlyCached)
{
// Convert all playernames to lowercase: