During the coding of a plugin, I wanted to check whether the UUID of a player to string, and the UUID given in the LoginPacket were similar, in order to execute more code, but found out this doesn't work a lot of the times. These two UUIDs differ for a very small bit, causing them not to be equal.
Following these steps, you sometimes happen to get a correct UUID, while other times you get a result resembling something like below.
"ab186c15-62dd-36cb-899e-9c810c6a3ba9""ab186c15-62dd-36cb-b99e-9c810c6a3ba9"As you can see in those two UUIDs, they're almost 100% identical, except for the -899e/b99e- part.
How is this even possible? Since the UUID is set from the login packet...
EDIT: Possibly related to https://github.com/PocketMine/PocketMine-MP/issues/3566 (opened by a Mineplex dev)
I think the issue is an oversimplification of UUID variant validity. The character which switched to an 8 there may be any of 8, 9, A, or B in a valid RFC 4122 UUID. The UUID implementation as a whole lacks the real meat of a UUID implementation.
Regardless, you'd be wiser to store the UUID in its raw form (toBinary()) and compare the binary forms, instead of using the string representation.
You have to use toString() though, if you're comparing it against the LoginPacket UUID.
$uuid = UUID::fromString($packet->clientUUID)->toBinary();
Most helpful comment
https://github.com/pmmp/PocketMine-MP/blob/24bdf330d550c8d9398adadfb6f28f6a758d5811/src/pocketmine/utils/UUID.php#L98
EDIT: Possibly related to https://github.com/PocketMine/PocketMine-MP/issues/3566 (opened by a Mineplex dev)