HypixelDev / PublicAPI

Official Java implementation of the Hypixel Public API.
https://api.hypixel.net
MIT License
535 stars 151 forks source link

Hypixel API Returns Integer on GuildReply for guild.guildExpByGameType, causing NumberFormatException #570

Closed DersWasTaken closed 1 year ago

DersWasTaken commented 1 year ago

Hello! I recently was working on a JDA Discord Bot which accesses the api, when I came across an error.

Exception in thread "DefaultDispatcher-worker-2" java.lang.IllegalStateException: java.util.concurrent.ExecutionException: com.google.gson.JsonSyntaxException: java.lang.NumberFormatException: Expected an int but was 2687175922 at line 1 column 31206 path $.guild.guildExpByGameType.

This seemingly happens because in GuildReply the guildExpByGameType is a <GameType, Integer> map, but in certain instances, for example "The Dawns Awakening" guild, the actual number is larger than Integer.MAX.

This can easily be fixed by changing it from a Int to a Double/Long.

It is currently late at night for me, so I cannot make a PR, but if one is not made by tomorrow I will do so.

DersWasTaken commented 1 year ago

Note, the error is being thrown when attempting to get the guild data, NOT when trying to get the guild exp for a specific gamemode

Sample Code:

val guild = DawnBot.api.getGuildByPlayer(uuid).get()
DersWasTaken commented 1 year ago

Just found a PR with the exact same issue and a fix for it, its been 117 days since the PR was made. https://github.com/HypixelDev/PublicAPI/issues/536

ElotherYT commented 1 year ago

I've been getting the exact same issue, is there an ETA of when this would be resolved by?

ConnorLinfoot commented 1 year ago

Fixed in #553