Skip to content

Commit 7317a04

Browse files
authored
Don't store Buddy and PokemonDetail protos (#822)
1 parent 19eec40 commit 7317a04

File tree

6 files changed

+132
-59
lines changed

6 files changed

+132
-59
lines changed

library/src/main/java/com/pokegoapi/api/PokemonGo.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ public void login(CredentialProvider credentialProvider)
190190
inventories = new Inventories(this);
191191
settings = new Settings(this);
192192
playerProfile = new PlayerProfile(this);
193+
playerProfile.updateProfile();
193194

194195
initialize();
195196

library/src/main/java/com/pokegoapi/api/map/Point.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ public Point(SpawnPointOuterClass.SpawnPoint spawnpoint) {
4242

4343
@Override
4444
public String toString() {
45-
return this.latitude + ", " + this.longitude;
45+
StringBuilder builder = new StringBuilder();
46+
builder.append(this.latitude);
47+
builder.append(", ");
48+
builder.append(this.longitude);
49+
return builder.toString();
4650
}
4751
}

library/src/main/java/com/pokegoapi/api/player/PlayerProfile.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,6 @@ public class PlayerProfile {
104104
public PlayerProfile(PokemonGo api) throws LoginFailedException, CaptchaActiveException, RemoteServerException {
105105
this.api = api;
106106
this.playerLocale = new PlayerLocale();
107-
108-
if (playerData == null) {
109-
updateProfile();
110-
}
111107
}
112108

113109
/**

library/src/main/java/com/pokegoapi/api/pokemon/Buddy.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020

2121
public class Buddy {
2222
private final PokemonGo api;
23-
private final BuddyPokemon proto;
23+
private long id;
24+
private double lastKMAwarded;
25+
private double startKM;
2426
private Pokemon pokemon;
2527
private double buddyDistance;
2628

@@ -31,15 +33,17 @@ public class Buddy {
3133
*/
3234
public Buddy(PokemonGo api, BuddyPokemon proto) {
3335
this.api = api;
34-
this.proto = proto;
36+
this.id = proto.getId();
37+
this.lastKMAwarded = proto.getLastKmAwarded();
38+
this.startKM = proto.getStartKmWalked();
3539
}
3640

3741
/**
3842
* @return the pokemon object of this buddy
3943
*/
4044
public Pokemon getPokemon() {
4145
if (pokemon == null) {
42-
pokemon = api.getInventories().getPokebank().getPokemonById(proto.getId());
46+
pokemon = api.getInventories().getPokebank().getPokemonById(this.id);
4347
buddyDistance = PokemonMetaRegistry.getMeta(pokemon.getPokemonId()).getBuddyDistance();
4448
}
4549
return pokemon;
@@ -59,14 +63,14 @@ public double getBuddyDistance() {
5963
* @return the last walk distance when a candy was received
6064
*/
6165
public double getLastReceiveKM() {
62-
return proto.getLastKmAwarded();
66+
return lastKMAwarded;
6367
}
6468

6569
/**
6670
* @return the distance when the distance started progressing
6771
*/
6872
public double getStartKM() {
69-
return proto.getStartKmWalked();
73+
return startKM;
7074
}
7175

7276
/**

library/src/main/java/com/pokegoapi/api/pokemon/Pokemon.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ public UpgradePokemonResponse.Result call(ByteString result) {
238238
throw new AsyncRemoteServerException(e);
239239
}
240240
//set new pokemon details
241-
setProto(response.getUpgradedPokemon());
241+
applyProto(response.getUpgradedPokemon());
242242
return response.getResult();
243243
}
244244
});

0 commit comments

Comments
 (0)