use of POGOProtos.Networking.Responses.SetAvatarResponseOuterClass.SetAvatarResponse in project PokeGOAPI-Java by Grover-c13.
the class PlayerProfile method setupAvatar.
/**
* Setup an avatar for the current account
*
* @throws RequestFailedException if an exception occurred while sending requests
*/
public void setupAvatar() throws RequestFailedException {
SecureRandom random = new SecureRandom();
PlayerGender gender = random.nextInt(100) % 2 == 0 ? PlayerGender.FEMALE : PlayerGender.MALE;
PlayerAvatar avatar = new PlayerAvatar(gender, random.nextInt(PlayerAvatar.getAvailableSkins()), random.nextInt(PlayerAvatar.getAvailableHair()), random.nextInt(PlayerAvatar.getAvailableShirts(gender)), random.nextInt(PlayerAvatar.getAvailablePants(gender)), random.nextInt(PlayerAvatar.getAvailableHats()), random.nextInt(PlayerAvatar.getAvailableShoes()), random.nextInt(PlayerAvatar.getAvailableEyes()), random.nextInt(PlayerAvatar.getAvailableBags(gender)));
List<TutorialListener> listeners = api.getListeners(TutorialListener.class);
for (TutorialListener listener : listeners) {
PlayerAvatar listenerAvatar = listener.selectAvatar(api);
if (listenerAvatar != null) {
avatar = listenerAvatar;
break;
}
}
final SetAvatarMessage setAvatarMessage = SetAvatarMessage.newBuilder().setPlayerAvatar(avatar.getAvatar()).build();
ServerRequest request = new ServerRequest(RequestType.SET_AVATAR, setAvatarMessage);
api.getRequestHandler().sendServerRequests(request, true);
try {
SetAvatarResponse setAvatarResponse = SetAvatarResponse.parseFrom(request.getData());
playerData = setAvatarResponse.getPlayerData();
updateProfile(playerData);
} catch (InvalidProtocolBufferException e) {
throw new RequestFailedException(e);
}
markTutorial(TutorialStateOuterClass.TutorialState.AVATAR_SELECTION);
api.getAssetDigest();
}
Aggregations