use of POGOProtos.Networking.Requests.Messages.FortSearchMessageOuterClass.FortSearchMessage in project PokeGOAPI-Java by Grover-c13.
the class Pokestop method lootAsync.
/**
* Loots a pokestop for pokeballs and other items.
*
* @return PokestopLootResult
*/
public Observable<PokestopLootResult> lootAsync() {
FortSearchMessage searchMessage = FortSearchMessage.newBuilder().setFortId(getId()).setFortLatitude(getLatitude()).setFortLongitude(getLongitude()).setPlayerLatitude(api.getLatitude()).setPlayerLongitude(api.getLongitude()).build();
ServerRequest serverRequest = new ServerRequest(RequestTypeOuterClass.RequestType.FORT_SEARCH, searchMessage);
return api.getRequestHandler().sendAsyncServerRequests(serverRequest, true).map(new Func1<ByteString, PokestopLootResult>() {
@Override
public PokestopLootResult call(ByteString result) {
FortSearchResponseOuterClass.FortSearchResponse response;
try {
response = FortSearchResponseOuterClass.FortSearchResponse.parseFrom(result);
} catch (InvalidProtocolBufferException e) {
throw Exceptions.propagate(e);
}
cooldownCompleteTimestampMs = response.getCooldownCompleteTimestampMs();
PokestopLootResult lootResult = new PokestopLootResult(response);
List<PokestopListener> listeners = api.getListeners(PokestopListener.class);
for (PokestopListener listener : listeners) {
// listener.onLoot(lootResult);
// return the pokestop, also change in listener
listener.onLoot(lootResult, Pokestop.this);
}
return lootResult;
}
});
}
Aggregations