@@ -99,8 +99,8 @@ public class PlayerProfile {
99
99
100
100
/**
101
101
* @param api the api
102
- * @throws LoginFailedException when the auth is invalid
103
- * @throws RemoteServerException when the server is down/having issues
102
+ * @throws LoginFailedException when the auth is invalid
103
+ * @throws RemoteServerException when the server is down/having issues
104
104
* @throws CaptchaActiveException if a captcha is active and the message can't be sent
105
105
*/
106
106
public PlayerProfile (PokemonGo api ) throws LoginFailedException , CaptchaActiveException , RemoteServerException {
@@ -111,8 +111,8 @@ public PlayerProfile(PokemonGo api) throws LoginFailedException, CaptchaActiveEx
111
111
/**
112
112
* Updates the player profile with the latest data.
113
113
*
114
- * @throws LoginFailedException when the auth is invalid
115
- * @throws RemoteServerException when the server is down/having issues
114
+ * @throws LoginFailedException when the auth is invalid
115
+ * @throws RemoteServerException when the server is down/having issues
116
116
* @throws CaptchaActiveException if a captcha is active and the message can't be sent
117
117
*/
118
118
public void updateProfile () throws RemoteServerException , CaptchaActiveException , LoginFailedException {
@@ -174,9 +174,9 @@ public void updateProfile(PlayerData playerData) {
174
174
/**
175
175
* Performs a GET_PLAYER_PROFILE request.
176
176
*
177
- * @throws RemoteServerException if the server has an issue or an invalid request is sent
177
+ * @throws RemoteServerException if the server has an issue or an invalid request is sent
178
178
* @throws CaptchaActiveException if a captcha is active, and the message cannot be sent
179
- * @throws LoginFailedException if login fails
179
+ * @throws LoginFailedException if login fails
180
180
*/
181
181
public void getProfile () throws RemoteServerException , CaptchaActiveException , LoginFailedException {
182
182
GetPlayerProfileMessage profileMessage = GetPlayerProfileMessage .newBuilder ()
@@ -208,9 +208,9 @@ public void getProfile() throws RemoteServerException, CaptchaActiveException, L
208
208
*
209
209
* @param level the trainer level that you want to accept the rewards for
210
210
* @return a PlayerLevelUpRewards object containing information about the items rewarded and unlocked for this level
211
- * @throws LoginFailedException when the auth is invalid
212
- * @throws RemoteServerException when the server is down/having issues
213
- * @throws CaptchaActiveException if a captcha is active and the message can't be sent
211
+ * @throws LoginFailedException when the auth is invalid
212
+ * @throws RemoteServerException when the server is down/having issues
213
+ * @throws CaptchaActiveException if a captcha is active and the message can't be sent
214
214
* @throws InsufficientLevelException if you have not yet reached the desired level
215
215
* @see PlayerLevelUpRewards
216
216
*/
@@ -241,7 +241,7 @@ public PlayerLevelUpRewards acceptLevelUpRewards(int level)
241
241
/**
242
242
* Add currency.
243
243
*
244
- * @param name the name
244
+ * @param name the name
245
245
* @param amount the amount
246
246
* @throws InvalidCurrencyException the invalid currency exception
247
247
*/
@@ -258,8 +258,8 @@ public void addCurrency(String name, int amount) throws InvalidCurrencyException
258
258
/**
259
259
* Check and equip badges.
260
260
*
261
- * @throws LoginFailedException when the auth is invalid
262
- * @throws RemoteServerException When a buffer exception is thrown
261
+ * @throws LoginFailedException when the auth is invalid
262
+ * @throws RemoteServerException When a buffer exception is thrown
263
263
* @throws CaptchaActiveException if a captcha is active and the message can't be sent
264
264
* @deprecated use getMedals, which uses common requests to check for badges
265
265
*/
@@ -297,8 +297,8 @@ public int getCurrency(Currency currency) {
297
297
*
298
298
* @param response the response to get badges from
299
299
* @throws CaptchaActiveException if a captcha is active and the message can't be sent
300
- * @throws LoginFailedException if login fails
301
- * @throws RemoteServerException if the server has an issue
300
+ * @throws LoginFailedException if login fails
301
+ * @throws RemoteServerException if the server has an issue
302
302
*/
303
303
public void updateAwardedMedals (CheckAwardedBadgesResponse response )
304
304
throws CaptchaActiveException , LoginFailedException , RemoteServerException {
@@ -432,8 +432,8 @@ public boolean hasBuddy() {
432
432
*
433
433
* @param pokemon the pokemon to set as your buddy
434
434
* @return if this task was successfull
435
- * @throws LoginFailedException when the auth is invalid
436
- * @throws RemoteServerException when the server is down/having issues
435
+ * @throws LoginFailedException when the auth is invalid
436
+ * @throws RemoteServerException when the server is down/having issues
437
437
* @throws CaptchaActiveException if a captcha is active and the message can't be sent
438
438
*/
439
439
public boolean setBuddy (Pokemon pokemon ) throws CaptchaActiveException , LoginFailedException , RemoteServerException {
@@ -454,8 +454,8 @@ public boolean setBuddy(Pokemon pokemon) throws CaptchaActiveException, LoginFai
454
454
/**
455
455
* Set the account to legal screen in order to receive valid response
456
456
*
457
- * @throws LoginFailedException when the auth is invalid
458
- * @throws RemoteServerException when the server is down/having issues
457
+ * @throws LoginFailedException when the auth is invalid
458
+ * @throws RemoteServerException when the server is down/having issues
459
459
* @throws CaptchaActiveException if a captcha is active and the message can't be sent
460
460
*/
461
461
public void activateAccount () throws LoginFailedException , CaptchaActiveException , RemoteServerException {
@@ -465,8 +465,8 @@ public void activateAccount() throws LoginFailedException, CaptchaActiveExceptio
465
465
/**
466
466
* Setup an avatar for the current account
467
467
*
468
- * @throws LoginFailedException when the auth is invalid
469
- * @throws RemoteServerException when the server is down/having issues
468
+ * @throws LoginFailedException when the auth is invalid
469
+ * @throws RemoteServerException when the server is down/having issues
470
470
* @throws CaptchaActiveException if a captcha is active and the message can't be sent
471
471
*/
472
472
public void setupAvatar () throws LoginFailedException , CaptchaActiveException , RemoteServerException {
@@ -517,8 +517,8 @@ public void setupAvatar() throws LoginFailedException, CaptchaActiveException, R
517
517
/**
518
518
* Encounter tutorial complete. In other words, catch the first Pokémon
519
519
*
520
- * @throws LoginFailedException when the auth is invalid
521
- * @throws RemoteServerException when the server is down/having issues
520
+ * @throws LoginFailedException when the auth is invalid
521
+ * @throws RemoteServerException when the server is down/having issues
522
522
* @throws CaptchaActiveException if a captcha is active and the message can't be sent
523
523
*/
524
524
public void encounterTutorialComplete () throws LoginFailedException , CaptchaActiveException , RemoteServerException {
@@ -558,23 +558,23 @@ public void encounterTutorialComplete() throws LoginFailedException, CaptchaActi
558
558
/**
559
559
* Setup an user name for our account
560
560
*
561
- * @throws LoginFailedException when the auth is invalid
562
- * @throws RemoteServerException when the server is down/having issues
561
+ * @throws LoginFailedException when the auth is invalid
562
+ * @throws RemoteServerException when the server is down/having issues
563
563
* @throws CaptchaActiveException if a captcha is active and the message can't be sent
564
564
*/
565
- public void claimCodeName () throws LoginFailedException , CaptchaActiveException , RemoteServerException {
566
- claimCodeName (null );
565
+ public String claimCodeName () throws LoginFailedException , CaptchaActiveException , RemoteServerException {
566
+ return claimCodeName (null );
567
567
}
568
568
569
569
/**
570
570
* Setup an user name for our account
571
571
*
572
572
* @param lastFailure the last name used that was already taken; null for first try.
573
- * @throws LoginFailedException when the auth is invalid
574
- * @throws RemoteServerException when the server is down/having issues
573
+ * @throws LoginFailedException when the auth is invalid
574
+ * @throws RemoteServerException when the server is down/having issues
575
575
* @throws CaptchaActiveException if a captcha is active and the message can't be sent
576
576
*/
577
- public void claimCodeName (String lastFailure )
577
+ public String claimCodeName (String lastFailure )
578
578
throws LoginFailedException , CaptchaActiveException , RemoteServerException {
579
579
if (getPlayerData ().getRemainingCodenameClaims () <= 0 ) {
580
580
throw new RuntimeException ("You have no remaining codename claims!" );
@@ -602,41 +602,38 @@ public void claimCodeName(String lastFailure)
602
602
String updatedCodename = null ;
603
603
try {
604
604
ClaimCodenameResponse claimCodenameResponse = ClaimCodenameResponse .parseFrom (request .getData ());
605
- if (claimCodenameResponse .getStatus () == ClaimCodenameResponse .Status .SUCCESS ) {
606
- updatedCodename = claimCodenameResponse .getCodename ();
607
- } else {
608
- claimCodeName (name );
605
+ if (claimCodenameResponse .getStatus () != ClaimCodenameResponse .Status .SUCCESS ) {
606
+ return claimCodeName (name );
609
607
}
608
+ updatedCodename = claimCodenameResponse .getCodename ();
609
+
610
610
if (claimCodenameResponse .hasUpdatedPlayer ()) {
611
611
updateProfile (claimCodenameResponse .getUpdatedPlayer ());
612
612
}
613
- } catch (InvalidProtocolBufferException e ) {
614
- throw new RemoteServerException (e );
615
- }
616
613
617
- if (updatedCodename != null ) {
618
- markTutorial (TutorialStateOuterClass .TutorialState .NAME_SELECTION );
614
+ if (updatedCodename != null ) {
615
+ markTutorial (TutorialStateOuterClass .TutorialState .NAME_SELECTION );
619
616
620
- final GetPlayerMessage getPlayerReqMsg = GetPlayerMessage .newBuilder ()
621
- .setPlayerLocale (playerLocale .getPlayerLocale ())
622
- .build ();
623
- request = new ServerRequest (RequestType .GET_PLAYER , getPlayerReqMsg );
617
+ final GetPlayerMessage getPlayerReqMsg = GetPlayerMessage .newBuilder ()
618
+ .setPlayerLocale (playerLocale .getPlayerLocale ())
619
+ .build ();
620
+ request = new ServerRequest (RequestType .GET_PLAYER , getPlayerReqMsg );
624
621
625
- api .getRequestHandler ().sendServerRequests (request .withCommons ());
622
+ api .getRequestHandler ().sendServerRequests (request .withCommons ());
626
623
627
- try {
628
624
updateProfile (GetPlayerResponse .parseFrom (request .getData ()));
629
- } catch (InvalidProtocolBufferException e ) {
630
- throw new RemoteServerException (e );
631
625
}
626
+ } catch (InvalidProtocolBufferException e ) {
627
+ throw new RemoteServerException (e );
632
628
}
629
+ return updatedCodename ;
633
630
}
634
631
635
632
/**
636
633
* The last step, mark the last tutorial state as completed
637
634
*
638
- * @throws LoginFailedException when the auth is invalid
639
- * @throws RemoteServerException when the server is down/having issues
635
+ * @throws LoginFailedException when the auth is invalid
636
+ * @throws RemoteServerException when the server is down/having issues
640
637
* @throws CaptchaActiveException if a captcha is active and the message can't be sent
641
638
*/
642
639
public void firstTimeExperienceComplete ()
@@ -674,4 +671,4 @@ private static String randomCodenameGenerator() {
674
671
}
675
672
return sb .toString ();
676
673
}
677
- }
674
+ }
0 commit comments