Question on offline UUIDs
#1
Let's say I have an 'offline' server. Will a username always map directly to a UUID? Obviously this is NOT a Mojang UUID and should not be expected to be the same if the server is ever put into online mode (or was taken off online mode). 

So if username 'BlueSky' logs into the offline server from home, they get assigned #UUID1#.

Assume that 'BlueSky' logs in again two months later from school. Will they still get assigned #UUID1# ? Is there any chance that someone with a username OTHER THAN 'BlueSky' gets this offline UUID?


Related note: I did a search for things about UUIDs on the forum. Didn't notice this topic come up, but I saw it mentioned a few times that there might be a callback based async MojangAPI thing written so that plugins could query it without blocking the server. Did that ever happen?
I sometimes write plugins! But I've not really "published" any of them, except my first, and worst, one. Feel free to explore my stuff here: my github page
Reply
Thanks given by:
#2
Yes, the offline UUID is generated based on their username, so it stays the same. The chance of a collision is rather low, it is assumed safe for identification. Internally, MD5 of the lowercased username is used for the offline UUIDs.

The non-blocking MojangAPI has not been implemented yet. There's even no issue for it on GitHub, I just created it:
https://github.com/cuberite/cuberite/issues/3640

Anyway, if you only query UUIDs of players who have already connected to your server, even the synchronous API is kinda safe, because the UUIDs are cached, so it returns the UUID from cache, rather than making a network request.

Theoretically, you could even implement the MojangAPI requests in your plugin using cNetwork or cUrlClient functions, but it's like "preinventing" the wheel Smile
Reply
Thanks given by:
#3
Thanks much. Much nicer to store things by UUID.

Yes, at this time I plan to only query previously online users.

I can't say I'd look forward to 'preinventing' the wheel, as you put it. I don't think I'd even need the functionality just yet, it was mostly a curiosity.
I sometimes write plugins! But I've not really "published" any of them, except my first, and worst, one. Feel free to explore my stuff here: my github page
Reply
Thanks given by:
#4
Just to verify, if I wanted to create the offline UUID for a player while the server was in online mode, I could do such with:

Code:
cCryptoHash.md5(cPlayer:GetName():lower())

correct?
I sometimes write plugins! But I've not really "published" any of them, except my first, and worst, one. Feel free to explore my stuff here: my github page
Reply
Thanks given by:
#5
No, you'll want to do something like this:
cMojangAPI:GetUUIDFromPlayerName(playerName, true);
Reply
Thanks given by:
#6
The problem currently with cMojangAPI is, that it blocks the server. There is a open issue on github.
For now I think cUrlClient could be used. The requests are done asynchronous and this won't block the server.
cUrlClient:Get("https://api.mojang.com/users/profiles/minecraft/<username>",
 function (a_Body, a_Data)
 if (a_Body) then
 -- Response received correctly, a_Body contains the entire response body,
 -- a_Data is a dictionary-table of the response\'s HTTP headers
 local tbUUIDName = cJson:Parse(a_Body)
 LOG(tbUUIDName.id)
 LOG(tbUUIDName.name)
 else
 -- There was an error, a_Data is the error message string
 LOG(a_Data)
 end
 end
)

LOG("Request sent.")

Result for my username:
4fd9f50b6b6143f7a99b8b5be71b52c3
Seadragon91

Source:
http://wiki.vg/Mojang_API#Username_-.3E_UUID_at_time
https://api.cuberite.org/cUrlClient.html
Reply
Thanks given by:
#7
The easiest way to get the offline UUIDs is to use the API function cClientHandle:GenerateOfflineUUID("playername")
https://api.cuberite.org/cClientHandle.h...lineUUID_1
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)