Reworked pets to deprecate enums & use pet endpoint #557
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reworked pets API to use the endpoint added by @ConnorLinfoot (#495 (comment)) 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 aMap<IPetType, Pet>
instead ofMap<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'sPlayer#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