Search in sources :

Example 1 with GetHoloInventoryMessage

use of POGOProtos.Networking.Requests.Messages.GetHoloInventoryMessageOuterClass.GetHoloInventoryMessage in project PokeGOAPI-Java by Grover-c13.

the class Inventories method updateInventories.

/**
 * Updates the inventories with the latest data.
 *
 * @param forceUpdate For a full update if true
 * @return the response to the update message
 * @throws RequestFailedException if an exception occurred while sending requests
 * @deprecated Inventory is updated as a common request
 */
@Deprecated
public GetHoloInventoryResponse updateInventories(boolean forceUpdate) throws RequestFailedException {
    if (forceUpdate) {
        lastInventoryUpdate = 0;
        itemBag.reset();
        pokebank.reset();
        candyjar.reset();
        pokedex.reset();
        synchronized (this.lock) {
            incubators.clear();
        }
        hatchery.reset();
    }
    GetHoloInventoryMessage invReqMsg = GetHoloInventoryMessage.newBuilder().setLastTimestampMs(lastInventoryUpdate).build();
    ServerRequest inventoryRequest = new ServerRequest(RequestType.GET_HOLOHOLO_INVENTORY, invReqMsg);
    api.requestHandler.sendServerRequests(inventoryRequest, false);
    GetHoloInventoryResponse response;
    try {
        response = GetHoloInventoryResponse.parseFrom(inventoryRequest.getData());
    } catch (InvalidProtocolBufferException e) {
        throw new RequestFailedException(e);
    }
    return response;
}
Also used : RequestFailedException(com.pokegoapi.exceptions.request.RequestFailedException) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) GetHoloInventoryMessage(POGOProtos.Networking.Requests.Messages.GetHoloInventoryMessageOuterClass.GetHoloInventoryMessage) ServerRequest(com.pokegoapi.main.ServerRequest) GetHoloInventoryResponse(POGOProtos.Networking.Responses.GetHoloInventoryResponseOuterClass.GetHoloInventoryResponse)

Example 2 with GetHoloInventoryMessage

use of POGOProtos.Networking.Requests.Messages.GetHoloInventoryMessageOuterClass.GetHoloInventoryMessage in project PokeGOAPI-Java by Grover-c13.

the class CommonRequests method getInventory.

/**
 * Creates a default GET_INVENTORY request
 *
 * @param api the current api
 * @return the constructed request
 */
public static ServerRequest getInventory(PokemonGo api) {
    long lastUpdate = api.inventories.lastInventoryUpdate;
    GetHoloInventoryMessage message = GetHoloInventoryMessage.newBuilder().setLastTimestampMs(lastUpdate).build();
    return new ServerRequest(RequestType.GET_HOLOHOLO_INVENTORY, message);
}
Also used : GetHoloInventoryMessage(POGOProtos.Networking.Requests.Messages.GetHoloInventoryMessageOuterClass.GetHoloInventoryMessage)

Aggregations

GetHoloInventoryMessage (POGOProtos.Networking.Requests.Messages.GetHoloInventoryMessageOuterClass.GetHoloInventoryMessage)2 GetHoloInventoryResponse (POGOProtos.Networking.Responses.GetHoloInventoryResponseOuterClass.GetHoloInventoryResponse)1 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 RequestFailedException (com.pokegoapi.exceptions.request.RequestFailedException)1 ServerRequest (com.pokegoapi.main.ServerRequest)1