use of com.pokegoapi.main.ServerRequest in project PokeGOAPI-Java by Grover-c13.
the class IncenseEncounter method encounter.
@Override
public EncounterResult encounter() throws RequestFailedException {
IncenseEncounterMessage message = IncenseEncounterMessage.newBuilder().setEncounterId(pokemon.getEncounterId()).setEncounterLocation(pokemon.getSpawnPointId()).build();
ServerRequest request = new ServerRequest(RequestType.INCENSE_ENCOUNTER, message);
ByteString responseData = api.getRequestHandler().sendServerRequests(request, true);
try {
IncenseEncounterResponse response = IncenseEncounterResponse.parseFrom(responseData);
encounterResult = EncounterResult.from(response.getResult());
activeItem = response.getActiveItem();
captureProbabilities = response.getCaptureProbability();
encounteredPokemon = response.getPokemonData();
} catch (InvalidProtocolBufferException e) {
throw new RequestFailedException(e);
}
return encounterResult;
}
use of com.pokegoapi.main.ServerRequest in project PokeGOAPI-Java by Grover-c13.
the class Settings method updateSettings.
/**
* Updates settings latest data.
*
* @throws RequestFailedException if an exception occurred while sending requests
*/
public void updateSettings() throws RequestFailedException {
DownloadSettingsMessageOuterClass.DownloadSettingsMessage msg = DownloadSettingsMessageOuterClass.DownloadSettingsMessage.newBuilder().build();
ServerRequest serverRequest = new ServerRequest(RequestTypeOuterClass.RequestType.DOWNLOAD_SETTINGS, msg);
//here you marked everything as read
api.getRequestHandler().sendServerRequests(serverRequest, false);
DownloadSettingsResponseOuterClass.DownloadSettingsResponse response;
try {
response = DownloadSettingsResponseOuterClass.DownloadSettingsResponse.parseFrom(serverRequest.getData());
} catch (InvalidProtocolBufferException e) {
throw new RequestFailedException(e);
}
updateSettings(response);
}
Aggregations