ProxioDev / ValioBungee

Synchronize players data between BungeeCord / Velocity proxies
Eclipse Public License 1.0
191 stars 50 forks source link

Use PlayerDB.co for name lookups #82

Closed Techdaan closed 1 year ago

Techdaan commented 1 year ago

I noticed that currently name lookups for UUIDs that are not cached, are not supported in RedisBungee due to Mojang removing name history.

When looking at the usages, RedisBungee internally only uses the current name (So no need for full name historyy), so I moved name lookups to PlayerDB, which does not have API rate limits unlike Mojang's API.

Due to removing the NameFetcher#nameHistoryFromUuid, this might break backwards compatibility, but it should be easy to re-add the method and throw an exception like it does now.

closes #59

ham1255 commented 1 year ago

before merging, does this api provider need any kind of tos agreement?

anyways we might need to set user agent based on info provided in the site.

Other Information

The API has no rate limits in place, but we ask that you please include an identifying user-agent header in any requests that you make to the API, so we can contact you if necessary about your usage.

Techdaan commented 1 year ago

Yeah, I don't think there's any TOS agreements but I did forget to set an user agent.

Do you have any suggestions for the User-Agent header? Since this is a form, RedisBungee might be too vague, perhaps something like RedisBungee-ProxioDev?

ham1255 commented 1 year ago

One you suggested seems to be great

Techdaan commented 1 year ago

I just made the change, I haven't tested it yet though because I am currently busy with some other things. If you want to, I can make sure there's no errors when lookups are made later.

ham1255 commented 1 year ago

Done some testing it seems like its working and fetches the name perfectly.

fixes: #59

ham1255 commented 1 year ago

before merging this you can include this code in name fetcher class to maintain compatibility .

public static List<String> nameHistoryFromUuid(UUID uuid) throws IOException {
        String name = getName(uuid);
        if (name == null) return Collections.emptyList();
        return Collections.singletonList(name);
    }

for some reason ssh connections being dropped

Techdaan commented 1 year ago

Heyhey, I missed your message earlier. I just added that snippet :)