#Getting UUIDs

1 messages · Page 1 of 1 (latest)

ornate meteor
#

Heyo, newbie to spigot, please excuse my ignorance lol

I've managed to obtain the UUID of a given player via the Minecraft API- the reason I dont grab it from a player object in game is because I'm sourcing the username from a discord command- but when I try to convert that UUID into an OfflinePlayer object via getOfflinePlayer(), it gives me an error saying the UUID is invalid.

Relevant code:

OfflinePlayer player = plugin.getServer().getOfflinePlayer(java.util.UUID.fromString(resUUID)
java.lang.IllegalArgumentException: Invalid UUID string: cbf8d615b44049cc90de9e66d7c8ac53
sinful sparrow
#

Pretty sure you need the -'s

ornate meteor
#

oh hell DX

celest grail
#

It does need the -'s, yes

ornate meteor
#

the api doesnt provide those 😭

celest grail
#

so format the string

ornate meteor
#

uh, i dont know how 😬 what's the format of a UUID?

#

is there a set number of characters between each -?

celest grail
#

8 chars - 4 chars - 4 chars - 4 chars - 12 chars

ornate meteor
#

wow, alright cool

celest grail
#

069a79f4-44e9-4726-a5be-fca90e38aaf5 just like that

ornate meteor
#

so i've managed to format it, but it's still giving me a problem

#

well first here's the screenshot showing i formatted it

#

the player shows as null

#

whitelist.yml also does not include the username of the player

#

so it lets the whitelisted user onto the server but the file never updates with the username 🤔

#

is that a minecraft bug lmao

#

other than that weird bug, it seems to be working just fine 🤷‍♂️

#

im gonna keep this thread open just in case someone has a solution but otherwise im good to go

celest grail
#

I keep a cache of the last username associated with each UUID and use that for UUID -> name translation