use of POGOProtos.Networking.Requests.Messages.NicknamePokemonMessageOuterClass.NicknamePokemonMessage in project PokeGOAPI-Java by Grover-c13.
the class Pokemon method renamePokemon.
/**
* Rename pokemon nickname pokemon response . result.
*
* @param nickname the nickname
* @return the nickname pokemon response . result
* @throws RequestFailedException if an exception occurred while sending requests
*/
public NicknamePokemonResponse.Result renamePokemon(String nickname) throws RequestFailedException {
NicknamePokemonMessage reqMsg = NicknamePokemonMessage.newBuilder().setPokemonId(getId()).setNickname(nickname).build();
ServerRequest serverRequest = new ServerRequest(RequestType.NICKNAME_POKEMON, reqMsg);
api.requestHandler.sendServerRequests(serverRequest, true);
NicknamePokemonResponse response;
try {
response = NicknamePokemonResponse.parseFrom(serverRequest.getData());
if (response.getResult() == NicknamePokemonResponse.Result.SUCCESS) {
this.nickname = nickname;
}
} catch (InvalidProtocolBufferException e) {
throw new RequestFailedException(e);
}
api.inventories.pokebank.removePokemon(this);
return response.getResult();
}
Aggregations