PublicAPI
PublicAPI copied to clipboard
Reworked pets to deprecate enums & use pet endpoint
Reworked pets API to use the endpoint added by @ConnorLinfoot (https://github.com/HypixelDev/PublicAPI/pull/495#issuecomment-991637161) and to keep a backwards compatibility for people to be able to change before it gets removed.
The only breaking change is the return type of PetStat#getAllPets
which now returns a Map<IPetType, Pet>
instead of Map<PetType, Pet>
.
The right way of getting pets of a player is to get the pet repository first (HypixelAPI#getPetRepository()
) then use that repository in the Player's Player#getPetStats(IPetRepository)
method. Providing a null repository or not providing one at all (for backwards compatibility, see BackwardsCompatibilityPetRepositoryImpl), will use the old PetType and Rarity enums instead. Unknown pets and null values are expected through the pets api when using the deprecated enums.
For the repositories, even though there are several specific getters (by name, by rarity.. etc), pets are only stored in a single collection. I have made the choice of sacrificing some computing time when using those getters to save some RAM as these methods are not expected to be used widely.
For a complete example, see GetPetsExample in the examples modules.
The javadoc hasn't been done, I expect to have feedbacks on the rework before losing my head doing the javadocs