Skip to content

Commit 40ff0f6

Browse files
committed
Merge branch 'cleanup' into Development-origin
2 parents 34eb6e1 + d338a53 commit 40ff0f6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+421
-455
lines changed

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

+31-41
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
import lombok.Getter;
6363
import lombok.Setter;
6464
import okhttp3.OkHttpClient;
65-
6665
import java.io.IOException;
6766
import java.lang.reflect.Method;
6867
import java.util.ArrayList;
@@ -71,34 +70,32 @@
7170
import java.util.Random;
7271
import java.util.UUID;
7372

74-
7573
public class PokemonGo {
76-
7774
private static final java.lang.String TAG = PokemonGo.class.getSimpleName();
7875
private final Time time;
7976
@Getter
80-
private long startTime;
77+
public long startTime;
8178
@Getter
8279
private final byte[] sessionHash = new byte[32];
8380
@Getter
84-
RequestHandler requestHandler;
81+
public RequestHandler requestHandler;
8582
@Getter
86-
private PlayerProfile playerProfile;
83+
public PlayerProfile playerProfile;
8784
@Getter
88-
private Inventories inventories;
85+
public Inventories inventories;
8986
@Getter
90-
private double latitude;
87+
public double latitude;
9188
@Getter
92-
private double longitude;
89+
public double longitude;
9390
@Getter
9491
@Setter
95-
private double altitude;
92+
public double altitude;
9693
@Getter
9794
@Setter
98-
private double accuracy = 5;
95+
public double accuracy = 5;
9996
private CredentialProvider credentialProvider;
10097
@Getter
101-
private Settings settings;
98+
public Settings settings;
10299
private Map map;
103100
@Setter
104101
private DeviceInfo deviceInfo;
@@ -110,33 +107,26 @@ public class PokemonGo {
110107
public ActivityStatus activityStatus;
111108
@Setter
112109
@Getter
113-
private long seed;
110+
public long seed;
114111
@Getter
115112
@Setter
116113
public LocationFixes locationFixes;
117-
118114
@Setter
119115
private boolean hasChallenge;
120116
@Getter
121117
private String challengeURL;
122118
private final Object challengeLock = new Object();
123-
124119
@Getter
125120
private List<Listener> listeners = Collections.synchronizedList(new ArrayList<Listener>());
126-
127121
private final Object lock = new Object();
128-
129122
@Getter
130-
private boolean loggingIn;
123+
public boolean loggingIn;
131124
@Getter
132125
private boolean active;
133-
134126
@Getter
135127
private Heartbeat heartbeat = new Heartbeat(this);
136-
137128
@Getter
138-
private HashProvider hashProvider;
139-
129+
public HashProvider hashProvider;
140130
private OkHttpClient client;
141131

142132
/**
@@ -146,19 +136,19 @@ public class PokemonGo {
146136
*/
147137
@Getter
148138
@Setter
149-
private boolean firstGMO = true;
139+
public boolean firstGMO = true;
150140
/**
151141
* Ptr8 is only sent with the first Get Player request,
152142
* we need a flag to tell us if it has already been sent.
153143
* after that, GET_PLAYER is sent with common requests.
154144
*/
155145
@Getter
156146
@Setter
157-
private boolean firstGP = true;
147+
public boolean firstGP = true;
158148

159149
@Getter
160150
@Setter
161-
private ItemTemplates itemTemplates;
151+
public ItemTemplates itemTemplates;
162152

163153
/**
164154
* Instantiates a new Pokemon go.
@@ -250,19 +240,19 @@ private void reset() {
250240
}
251241

252242
private void initialize() throws RequestFailedException {
253-
if (getRequestHandler() != null) {
254-
getRequestHandler().exit();
243+
if (requestHandler != null) {
244+
requestHandler.exit();
255245
}
256246

257247
requestHandler = new RequestHandler(this, client);
258248

259-
getRequestHandler().sendServerRequests(ServerRequestEnvelope.create());
249+
requestHandler.sendServerRequests(ServerRequestEnvelope.create());
260250

261251
playerProfile.updateProfile();
262252

263253
ServerRequest downloadConfigRequest = new ServerRequest(RequestType.DOWNLOAD_REMOTE_CONFIG_VERSION,
264254
CommonRequests.getDownloadRemoteConfigVersionMessageRequest(this));
265-
getRequestHandler().sendServerRequests(downloadConfigRequest, true);
255+
requestHandler.sendServerRequests(downloadConfigRequest, true);
266256
getAssetDigest();
267257

268258
try {
@@ -278,14 +268,14 @@ private void initialize() throws RequestFailedException {
278268

279269
try {
280270
LevelUpRewardsMessage rewardsMessage = LevelUpRewardsMessage.newBuilder()
281-
.setLevel(playerProfile.getLevel())
271+
.setLevel(playerProfile.getStats().getLevel())
282272
.build();
283273
ServerRequest request = new ServerRequest(RequestType.LEVEL_UP_REWARDS, rewardsMessage);
284274
ServerRequestEnvelope envelope = ServerRequestEnvelope.createCommons(request, this);
285-
getRequestHandler().sendServerRequests(envelope);
275+
requestHandler.sendServerRequests(envelope);
286276
LevelUpRewardsResponse levelUpRewardsResponse = LevelUpRewardsResponse.parseFrom(request.getData());
287277
if (levelUpRewardsResponse.getResult() == Result.SUCCESS) {
288-
inventories.getItemBag().addAwardedItems(levelUpRewardsResponse);
278+
inventories.itemBag.addAwardedItems(levelUpRewardsResponse);
289279
}
290280
} catch (InvalidProtocolBufferException e) {
291281
throw new RequestFailedException(e);
@@ -295,7 +285,7 @@ private void initialize() throws RequestFailedException {
295285
ServerRequestEnvelope envelope = ServerRequestEnvelope.create();
296286
envelope.addPlatform(new ServerPlatformRequest(PlatformRequestType.GET_STORE_ITEMS, getStoreItems));
297287

298-
getRequestHandler().sendServerRequests(envelope);
288+
requestHandler.sendServerRequests(envelope);
299289

300290
List<LoginListener> loginListeners = getListeners(LoginListener.class);
301291

@@ -322,7 +312,7 @@ private void initialize() throws RequestFailedException {
322312
playerProfile.encounterTutorialComplete();
323313
}
324314

325-
int remainingCodenameClaims = getPlayerProfile().getPlayerData().getRemainingCodenameClaims();
315+
int remainingCodenameClaims = playerProfile.getPlayerData().getRemainingCodenameClaims();
326316
if (!tutorialStates.contains(TutorialState.NAME_SELECTION) && remainingCodenameClaims > 0) {
327317
playerProfile.claimCodeName();
328318
}
@@ -340,7 +330,7 @@ private void initialize() throws RequestFailedException {
340330
public void getAssetDigest() throws RequestFailedException {
341331
GetAssetDigestMessage message = CommonRequests.getGetAssetDigestMessageRequest(this);
342332
ServerRequest request = new ServerRequest(RequestType.GET_ASSET_DIGEST, message);
343-
getRequestHandler().sendServerRequests(request, true);
333+
requestHandler.sendServerRequests(request, true);
344334
}
345335

346336
/**
@@ -395,8 +385,8 @@ public void setLocation(double latitude, double longitude, double altitude) {
395385
public void setLocation(double latitude, double longitude, double altitude, double accuracy) {
396386
setLatitude(latitude);
397387
setLongitude(longitude);
398-
setAltitude(altitude);
399-
setAccuracy(accuracy);
388+
//setAltitude(altitude);
389+
//setAccuracy(accuracy);
400390
}
401391

402392
public long currentTimeMillis() {
@@ -486,7 +476,7 @@ public SignatureOuterClass.Signature.DeviceInfo getDeviceInfo() {
486476
* @return the sensor info
487477
*/
488478
public SignatureOuterClass.Signature.SensorInfo getSensorSignature(long currentTime, Random random) {
489-
if (this.sensorInfo == null || sensorInfo.getTimestampCreate() != 0L) {
479+
if (this.sensorInfo == null || sensorInfo.timestampCreate != 0L) {
490480
return SensorInfo.getDefault(this, currentTime, random);
491481
}
492482
return sensorInfo.getSensorInfo();
@@ -620,7 +610,7 @@ public boolean verifyChallenge(String token) throws RequestFailedException {
620610
hasChallenge = false;
621611
VerifyChallengeMessage message = VerifyChallengeMessage.newBuilder().setToken(token).build();
622612
ServerRequest request = new ServerRequest(RequestType.VERIFY_CHALLENGE, message);
623-
ByteString responseData = getRequestHandler().sendServerRequests(request, true);
613+
ByteString responseData = requestHandler.sendServerRequests(request, true);
624614
try {
625615
VerifyChallengeResponse response = VerifyChallengeResponse.parseFrom(responseData);
626616
hasChallenge = !response.getSuccess();
@@ -648,7 +638,7 @@ public String checkChallenge() throws RequestFailedException {
648638
CheckChallengeMessage message = CheckChallengeMessage.newBuilder().build();
649639
try {
650640
ServerRequest request = new ServerRequest(RequestType.CHECK_CHALLENGE, message);
651-
ByteString responseData = getRequestHandler().sendServerRequests(request, false);
641+
ByteString responseData = requestHandler.sendServerRequests(request, false);
652642
CheckChallengeResponse response = CheckChallengeResponse.parseFrom(responseData);
653643
String newChallenge = response.getChallengeUrl();
654644
if (response.getShowChallenge() && newChallenge != null && newChallenge.length() > 0) {
@@ -665,7 +655,7 @@ public String checkChallenge() throws RequestFailedException {
665655
* @return the current player position in Point form
666656
*/
667657
public Point getPoint() {
668-
return new Point(this.getLatitude(), this.getLongitude());
658+
return new Point(this.latitude, this.longitude);
669659
}
670660

671661
/**

library/src/main/java/com/pokegoapi/api/device/ActivityStatus.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ public ActivityStatus() {
4343
*/
4444
public static SignatureOuterClass.Signature.ActivityStatus getDefault(PokemonGo api, Random random) {
4545
boolean tilting = random.nextInt() % 2 == 0;
46-
ActivityStatus activityStatus = api.getActivityStatus();
46+
ActivityStatus activityStatus = api.activityStatus;
4747
if (activityStatus == null) {
4848
activityStatus = new ActivityStatus();
49-
api.setActivityStatus(activityStatus);
49+
api.activityStatus = activityStatus;
5050
}
5151
activityStatus.setStationary(true);
5252
if (tilting) {

library/src/main/java/com/pokegoapi/api/device/DeviceInfo.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ private static String bytesToHex(byte[] bytes) {
9292
*/
9393
public static DeviceInfo getDefault(PokemonGo api) {
9494
DeviceInfo deviceInfo = new DeviceInfo();
95-
Random random = new Random(api.getSeed());
95+
Random random = new Random(api.seed);
9696
byte[] bytes = new byte[16];
9797
random.nextBytes(bytes);
9898
String[] device = DEVICES[random.nextInt(DEVICES.length)];

library/src/main/java/com/pokegoapi/api/device/LocationFixes.java

+14-14
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public LocationFixes() {
4040
*/
4141
public static LocationFixes getDefault(PokemonGo api, RequestEnvelopeOuterClass.RequestEnvelope.Builder builder,
4242
long currentTime, Random random) {
43-
if (Double.isNaN(api.getLatitude()) || Double.isNaN(api.getLongitude())) {
43+
if (Double.isNaN(api.latitude) || Double.isNaN(api.longitude)) {
4444
return new LocationFixes();
4545
}
4646

@@ -60,9 +60,9 @@ public static LocationFixes getDefault(PokemonGo api, RequestEnvelopeOuterClass.
6060

6161
int chance = random.nextInt(100);
6262
LocationFixes locationFixes;
63-
if (api.getLocationFixes() == null) {
63+
if (api.locationFixes == null) {
6464
locationFixes = new LocationFixes();
65-
api.setLocationFixes(locationFixes);
65+
api.locationFixes = locationFixes;
6666
providerCount = pn < 75 ? 6 : pn < 95 ? 5 : 8;
6767
if (providerCount != 8) {
6868
// a 5% chance that the second provider got a negative value else it should be the first only
@@ -77,12 +77,12 @@ public static LocationFixes getDefault(PokemonGo api, RequestEnvelopeOuterClass.
7777
}
7878
}
7979
} else {
80-
locationFixes = api.getLocationFixes();
80+
locationFixes = api.locationFixes;
8181
locationFixes.clear();
8282

83-
boolean expired = currentTime - locationFixes.getTimestampCreate() < (random.nextInt(10000) + 5000);
83+
boolean expired = currentTime - locationFixes.timestampCreate < (random.nextInt(10000) + 5000);
8484
if (empty || (!hasMapUpdate && expired)) {
85-
locationFixes.setTimestampCreate(currentTime);
85+
locationFixes.timestampCreate = currentTime;
8686
return locationFixes;
8787
} else if (hasMapUpdate) {
8888
providerCount = chance >= 90 ? 2 : 1;
@@ -91,17 +91,17 @@ public static LocationFixes getDefault(PokemonGo api, RequestEnvelopeOuterClass.
9191
}
9292
}
9393

94-
locationFixes.setTimestampCreate(currentTime);
94+
locationFixes.timestampCreate = currentTime;
9595

9696
for (int i = 0; i < providerCount; i++) {
97-
float latitude = (float) api.getLatitude();
98-
float longitude = (float) api.getLongitude();
97+
float latitude = (float) api.latitude;
98+
float longitude = (float) api.longitude;
9999
if (i < providerCount - 1) {
100-
latitude = offsetOnLatLong(api.getLatitude(), random.nextInt(100) + 10);
101-
longitude = offsetOnLatLong(api.getLongitude(), random.nextInt(100) + 10);
100+
latitude = offsetOnLatLong(api.latitude, random.nextInt(100) + 10);
101+
longitude = offsetOnLatLong(api.longitude, random.nextInt(100) + 10);
102102
}
103103

104-
float altitude = (float) api.getAltitude();
104+
float altitude = (float) api.altitude;
105105
float verticalAccuracy = (float) (15 + (23 - 15) * random.nextDouble());
106106

107107
// Fake errors
@@ -121,11 +121,11 @@ public static LocationFixes getDefault(PokemonGo api, RequestEnvelopeOuterClass.
121121
.setTimestampSnapshot(
122122
contains(negativeSnapshotProviders, i)
123123
? random.nextInt(1000) - 3000
124-
: currentTime - api.getStartTime()
124+
: currentTime - api.startTime
125125
+ (150 * (i + 1) + random.nextInt(250 * (i + 1) - (150 * (i + 1)))))
126126
.setLatitude(latitude)
127127
.setLongitude(longitude)
128-
.setHorizontalAccuracy((float) api.getAccuracy())
128+
.setHorizontalAccuracy((float) api.accuracy)
129129
.setAltitude(altitude)
130130
.setVerticalAccuracy(verticalAccuracy)
131131
.setProviderStatus(3L)

library/src/main/java/com/pokegoapi/api/device/SensorInfo.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class SensorInfo {
3232

3333
@Setter
3434
@Getter
35-
private long timestampCreate;
35+
public long timestampCreate;
3636

3737
public SensorInfo() {
3838
sensorInfoBuilder = SignatureOuterClass.Signature.SensorInfo.newBuilder();
@@ -73,10 +73,10 @@ public SensorInfo(SensorInfos sensorInfos) {
7373
*/
7474
public static SignatureOuterClass.Signature.SensorInfo getDefault(PokemonGo api, long currentTime, Random random) {
7575
SensorInfo sensorInfo;
76-
if (api.getSensorInfo() == null) {
76+
if (api.sensorInfo == null) {
7777
sensorInfo = new SensorInfo();
7878
sensorInfo.getBuilder()
79-
.setTimestampSnapshot(currentTime - api.getStartTime() + random.nextInt(500))
79+
.setTimestampSnapshot(currentTime - api.startTime + random.nextInt(500))
8080
.setRotationRateX(0.1 + 0.6 * random.nextDouble())
8181
.setRotationRateY(0.1 + 0.7000000000000001 * random.nextDouble())
8282
.setRotationRateZ(0.1 + 0.7000000000000001 * random.nextDouble())
@@ -88,11 +88,11 @@ public static SignatureOuterClass.Signature.SensorInfo getDefault(PokemonGo api,
8888
.setGravityZ(-1.0 + random.nextDouble() * 2.0)
8989
.setMagneticFieldAccuracy(-1)
9090
.setStatus(3);
91-
api.setSensorInfo(sensorInfo);
91+
api.sensorInfo = sensorInfo;
9292
} else {
93-
sensorInfo = api.getSensorInfo();
93+
sensorInfo = api.sensorInfo;
9494
sensorInfo.getBuilder()
95-
.setTimestampSnapshot(currentTime - api.getStartTime() + random.nextInt(500))
95+
.setTimestampSnapshot(currentTime - api.startTime + random.nextInt(500))
9696
.setLinearAccelerationX(-0.7 + random.nextDouble() * 1.4)
9797
.setLinearAccelerationY(-0.7 + random.nextDouble() * 1.4)
9898
.setLinearAccelerationZ(-0.7 + random.nextDouble() * 1.4)
@@ -108,8 +108,8 @@ public static SignatureOuterClass.Signature.SensorInfo getDefault(PokemonGo api,
108108
.setMagneticFieldAccuracy(-1)
109109
.setStatus(3);
110110
}
111-
if (currentTime - sensorInfo.getTimestampCreate() > (random.nextInt(10000) + 5000)) {
112-
sensorInfo.setTimestampCreate(currentTime);
111+
if (currentTime - sensorInfo.timestampCreate > (random.nextInt(10000) + 5000)) {
112+
sensorInfo.timestampCreate = currentTime;
113113
return sensorInfo.getSensorInfo();
114114
}
115115
return null;

0 commit comments

Comments
 (0)