Minecraft deprecated the uuid -> name API last night, 9/13/2022
Closed this issue · 4 comments
q23407u892f commented
This is now erroring out :(
https://github.com/Joshi425/minecraft-exporter/blob/master/minecraft_exporter.py#L42-L52
https://help.minecraft.net/hc/en-us/articles/8969841895693-Username-History-API-Removal-FAQ-
It does look like the player name is located in the .dat file though. I'm currently digging through the nbt.py docs to see how to query it
q23407u892f commented
ah, nbtfile.get('bukkit')['lastKnownName']
will give you the player name, assuming the server is using bukkit
q23407u892f commented
def uuid_to_player(self, uuid):
no_dash_uuid = uuid.replace('-', '')
if no_dash_uuid in self.player_map:
return self.player_map[no_dash_uuid]
else:
try:
# result = requests.get('https://api.mojang.com/user/profiles/' + uuid + '/names')
# return (result.json()[-1]['name'])
nbtfile = nbt.nbt.NBTFile(self.player_directory + "/" + uuid + ".dat", 'rb')
name = str(nbtfile.get('bukkit')['lastKnownName'])
self.player_map[no_dash_uuid] = name
return name
except:
return
Bibz87 commented
def uuid_to_player(self, uuid): no_dash_uuid = uuid.replace('-', '') if no_dash_uuid in self.player_map: return self.player_map[no_dash_uuid] else: try: # result = requests.get('https://api.mojang.com/user/profiles/' + uuid + '/names') # return (result.json()[-1]['name']) nbtfile = nbt.nbt.NBTFile(self.player_directory + "/" + uuid + ".dat", 'rb') name = str(nbtfile.get('bukkit')['lastKnownName']) self.player_map[no_dash_uuid] = name return name except: return
That wouldn't work on a Vanilla server, unfortunately. Maybe falling back to the UUID itself might be a somewhat OK-ish solution for Vanilla servers?