Joshi425/minecraft-exporter

Minecraft deprecated the uuid -> name API last night, 9/13/2022

Closed this issue · 4 comments

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

ah, nbtfile.get('bukkit')['lastKnownName'] will give you the player name, assuming the server is using bukkit

        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
        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?

I've replaced the history api with the sessionserver api:
53bd248
do docker pull joshi425/minecraft_exporter and restart the exporter to work again.
thanks for the issue