AmmoniumX / AdminShop

Admin Shop Minecraft Mod
GNU Lesser General Public License v2.1
4 stars 4 forks source link

Offline hack for MojangAPI.java #33

Closed Infro closed 1 month ago

Infro commented 6 months ago

Making it playable when offline instead of freezing for 6 seconds every time the shop is opened. This was quickly done on github.com so, no tests, no compile, and hopefully it's usable...

AmmoniumX commented 6 months ago

Hi, thanks for your contribution! So: in order to avoid freezes, you want to store the UUID as a fallback when there's no internet connection, so that it doesn't attempt connecting every time you open a menu, right? That would be useful, but I think it would be better if this instead only happened when the GET request returns an IOException, which occurs when you're offline or can't reach the server, so doing something like this instead:

catch (IOException e) {
            AdminShop.LOGGER.error("Network IO Exception while getting username.");
            storedResults.put(uuid, uuid);
            e.printStackTrace();
}

I think this would be better since there are cases where you would want to try again after failing once, such as being rate limited (429 Too Many Requests). Let me know if you agree with this change.

AmmoniumX commented 1 month ago

Added. Thanks for the feedback!