When i try to convert a username to a UUID using the mojang api, the response allways is in the {"username":username, "id":shortened UUID of the username} format. but my problem is, i need the UUID of the player for another API which requires a non shortened UUID, and gives a "malformed UUID" error when i try to do the request with a short UUID. the basic difference between short and long UUID's in minecraft is that the long one's contain multiple - whilst the short ones dont. Is there any way to convert that or another endpoint?
Asked
Active
Viewed 209 times
2 Answers
1
Mojang does not provide any endpoints to use dashed UUIDs instead, however there are many answers on how to insert dashes into the UUID. See Creating a UUID from a string with no dashes

UltraDev
- 21
- 4
0
You can use StringBuilder#insert(int, char) to insert dashes where they should be, it should look like this:
new StringBuilder("005056963AB75FD48BDC59C100314C40")
.insert(20, '-')
.insert(16, '-')
.insert(12, '-')
.insert(8, '-')
.toString();

GabyTM
- 1
- 1
- 3