Search in sources :

Example 1 with UseIncenseMessage

use of POGOProtos.Networking.Requests.Messages.UseIncenseMessageOuterClass.UseIncenseMessage in project PokeGOAPI-Java by Grover-c13.

the class ItemBag method useIncense.

/**
	 * use an incense
	 *
	 * @param type type of item
	 * @throws RequestFailedException if an exception occurred while sending requests
	 */
public void useIncense(ItemId type) throws RequestFailedException {
    UseIncenseMessage useIncenseMessage = UseIncenseMessage.newBuilder().setIncenseType(type).setIncenseTypeValue(type.getNumber()).build();
    ServerRequest useIncenseRequest = new ServerRequest(RequestType.USE_INCENSE, useIncenseMessage);
    api.getRequestHandler().sendServerRequests(useIncenseRequest, true);
    try {
        UseIncenseResponse response = UseIncenseResponse.parseFrom(useIncenseRequest.getData());
        Log.i("Main", "Use incense result: " + response.getResult());
    } catch (InvalidProtocolBufferException e) {
        throw new RequestFailedException(e);
    }
}
Also used : RequestFailedException(com.pokegoapi.exceptions.request.RequestFailedException) UseIncenseMessage(POGOProtos.Networking.Requests.Messages.UseIncenseMessageOuterClass.UseIncenseMessage) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) ServerRequest(com.pokegoapi.main.ServerRequest) UseIncenseResponse(POGOProtos.Networking.Responses.UseIncenseResponseOuterClass.UseIncenseResponse)

Aggregations

UseIncenseMessage (POGOProtos.Networking.Requests.Messages.UseIncenseMessageOuterClass.UseIncenseMessage)1 UseIncenseResponse (POGOProtos.Networking.Responses.UseIncenseResponseOuterClass.UseIncenseResponse)1 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 RequestFailedException (com.pokegoapi.exceptions.request.RequestFailedException)1 ServerRequest (com.pokegoapi.main.ServerRequest)1