Commit cca2a1c finds pokemon only once after running.
In Commit cca2a1c, go.getMap().getCatchablePokemon() only seems to find pokemons only once after launching. After catching pokemon, I have to terminate and rerun in order to find more.
this commit doesn´t changed the logic. You have to wait 5sec after every scan since the server update.
If I run my same code with commit 82fefdb6, it finds pokemons without any problem except getting stuck at cp.catchPokemon() once in a while. In cca2a1c, are you suggesting to run Thread.sleep(5000) before catchablePokemon = go.getMap().getCatchablePokemon();? Thanks,
On 8/1/2016 7:50 PM, Fabian Terhorst wrote:
this commit doesn´t changed the logic. You have to wait 5sec after every scan since the server update.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Grover-c13/PokeGOAPI-Java/issues/438#issuecomment-236745502, or mute the thread https://github.com/notifications/unsubscribe-auth/ALDSx1mndUMFxKtnz9h6wwQE1PnKkaCsks5qboZggaJpZM4JaG68.
There are logic changes from @jabbink in this commit.
from #426
does this is breaking the scan in your app?
Well, it finds once in the beginning. Then it breaks. I'm not sure exactly what the sequence is supposed to be. Here's my code for catching loop. This code works fine in commit 82fefdb except it hangs once in a while at cp.catchPokemon();. In cca2a1c , it only finds once in the beginning, and I have to terminate and rerun in order to find more. It'd be great if you could write a catching loop in the example.
while (true) {
int size = 0;
while (size == 0) {
Thread.sleep(1000);
catchablePokemon = go.getMap().getCatchablePokemon();
size = catchablePokemon.size();
}
System.out.println("Catching " + size + " Pokemons");
for (CatchablePokemon cp : catchablePokemon) {
PokemonId id = cp.getPokemonId();
EncounterResult encResult = cp.encounterPokemon();
System.out.println("Encountered: " + id + " " + encResult.getStatus());
if (!encResult.wasSuccessful()) continue;
CatchResult result = cp.catchPokemon();
System.out.println("Attempt to catch: " + id + " " + result.getStatus());
}
}
you need to change the sleep time to 5000 or otherwise it will only work once
and you may also need to add a Thread.sleep(5000) after encounterPokemon() and catchPokemon() for the same reason, but I'm not 100% sure about that one
I only know that 5 seconds is the minimum for scanning. Many people are saying there are using 6 seconds to be 100% sure.
The api currently implements this (it will use cached object for 5 seconds and request new one), im looking into an issue with the cache of catchable pokemon now, but looks like its running fine for me.
Is the wait before or after the first request?
it will use a fresh copy on the first request, then store it, and then any call for the next 5 seconds will return the cache copy, and then will request a new copy again for calls after that 5 seconds.
I thought about saving 50 pokemongo object references that are using 50 different accounts so that i can send a request every 0,1seconds.
If the api returns cache copy, wouldn't my loop eventually get a new scan every 5 seconds? It shouldn't break forever until restart though.
Yes you are correct, unless there is a flaw in the cache logic. Can you give me the long/lat so i can do some testing at that area to see if i can reproduce?
I'm just doing Central Park, New York.
On 8/2/2016 5:03 AM, Grover-c13 wrote:
Yes you are correct, unless there is a flaw in the cache logic. Can you give me the long/lat so i can do some testing at that area to see if i can reproduce?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Grover-c13/PokeGOAPI-Java/issues/438#issuecomment-236846414, or mute the thread https://github.com/notifications/unsubscribe-auth/ALDSx3rLbuhcvK8jeOXAlJcwzVnBKPicks5qbwfTgaJpZM4JaG68.
There's a flaw in the cache logic. If you call getCatchablePokemon for the first time, everything works. cachedCatchable is set to something not null. If you after this, do any call on getting the map and the timeout has expired, map objects are reloaded and cache timeout is reset. If you then get catchable pokemon, timeout is not expired and cachedCatchable is not null, so cachedCatchable is returned which by this time most likely is empty.
Setting cachedCatchable to null in the getMapObjectsAsync call will solve this.
yeah i think i did this in the latest PR, let me check
Here's a PR if it's still broken
https://github.com/Grover-c13/PokeGOAPI-Java/blob/0d9857633b92ebce4c7c8bc5c1b52bb891999b74/library/src/main/java/com/pokegoapi/api/map/Map.java#L98
https://github.com/Grover-c13/PokeGOAPI-Java/blob/0d9857633b92ebce4c7c8bc5c1b52bb891999b74/library/src/main/java/com/pokegoapi/api/map/Map.java#L378
yep did it