Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[BUG] queryHatchedEggs indexOutOfBoundsError #229

Closed
@Jari27

Description

@Jari27

Description:
pgo.getInvengetHatchery().queryHatchedEggs() sometimes throws an indexOutOfBoundsError. I suspect this is when an Egg has actually hatched

Steps to reproduce:

List<HatchedEgg> hatcheds = inventories.getHatchery().queryHatchedEggs();;
if (hatcheds.size() > 0) {
    TAG = "HATCHERY";
    for (HatchedEgg hatchedEgg : hatcheds) {
        Log.i(TAG, String.format("Congrats! You hatched an %s and received %d candies and %d stardust!", Inventories.getPokebank().getPokemonById(hatchedEgg.getId()).getPokemonId().toString().toLowerCase(), hatchedEgg.getCandy(), hatchedEgg.getStardust()));
    }
}

(also make sure there is an actual hatch -> implement walking code)

Expected behavior:
Print the string above or gracefully throw an error.

Actual behavior:
Crash due to IndexOutOfBoundsException

Stacktrace (If it's a crash):

Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
    at java.util.ArrayList.rangeCheck(Unknown Source)
    at java.util.ArrayList.get(Unknown Source)
    at java.util.Collections$UnmodifiableList.get(Unknown Source)
    at POGOProtos.Networking.Responses.GetHatchedEggsResponseOuterClass$GetHatchedEggsResponse.getExperienceAwarded(GetHatchedEggsResponseOuterClass.java:292)
    at com.pokegoapi.api.inventory.Hatchery.queryHatchedEggs(Hatchery.java:77)
    at some.package.SomeClass.someMethod(SomeClass:##)

Version:
Recent Development branch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions