Skip to content

Commit cb54310

Browse files
committed
cleanup
1 parent 34eb6e1 commit cb54310

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

+434
-459
lines changed

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

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -77,28 +77,28 @@ public class PokemonGo {
7777
private static final java.lang.String TAG = PokemonGo.class.getSimpleName();
7878
private final Time time;
7979
@Getter
80-
private long startTime;
80+
public long startTime;
8181
@Getter
8282
private final byte[] sessionHash = new byte[32];
8383
@Getter
84-
RequestHandler requestHandler;
84+
public RequestHandler requestHandler;
8585
@Getter
86-
private PlayerProfile playerProfile;
86+
public PlayerProfile playerProfile;
8787
@Getter
88-
private Inventories inventories;
88+
public Inventories inventories;
8989
@Getter
90-
private double latitude;
90+
public double latitude;
9191
@Getter
92-
private double longitude;
92+
public double longitude;
9393
@Getter
9494
@Setter
95-
private double altitude;
95+
public double altitude;
9696
@Getter
9797
@Setter
98-
private double accuracy = 5;
98+
public double accuracy = 5;
9999
private CredentialProvider credentialProvider;
100100
@Getter
101-
private Settings settings;
101+
public Settings settings;
102102
private Map map;
103103
@Setter
104104
private DeviceInfo deviceInfo;
@@ -110,7 +110,7 @@ public class PokemonGo {
110110
public ActivityStatus activityStatus;
111111
@Setter
112112
@Getter
113-
private long seed;
113+
public long seed;
114114
@Getter
115115
@Setter
116116
public LocationFixes locationFixes;
@@ -127,15 +127,15 @@ public class PokemonGo {
127127
private final Object lock = new Object();
128128

129129
@Getter
130-
private boolean loggingIn;
130+
public boolean loggingIn;
131131
@Getter
132132
private boolean active;
133133

134134
@Getter
135135
private Heartbeat heartbeat = new Heartbeat(this);
136136

137137
@Getter
138-
private HashProvider hashProvider;
138+
public HashProvider hashProvider;
139139

140140
private OkHttpClient client;
141141

@@ -146,19 +146,19 @@ public class PokemonGo {
146146
*/
147147
@Getter
148148
@Setter
149-
private boolean firstGMO = true;
149+
public boolean firstGMO = true;
150150
/**
151151
* Ptr8 is only sent with the first Get Player request,
152152
* we need a flag to tell us if it has already been sent.
153153
* after that, GET_PLAYER is sent with common requests.
154154
*/
155155
@Getter
156156
@Setter
157-
private boolean firstGP = true;
157+
public boolean firstGP = true;
158158

159159
@Getter
160160
@Setter
161-
private ItemTemplates itemTemplates;
161+
public ItemTemplates itemTemplates;
162162

163163
/**
164164
* Instantiates a new Pokemon go.
@@ -250,19 +250,19 @@ private void reset() {
250250
}
251251

252252
private void initialize() throws RequestFailedException {
253-
if (getRequestHandler() != null) {
254-
getRequestHandler().exit();
253+
if (requestHandler != null) {
254+
requestHandler.exit();
255255
}
256256

257257
requestHandler = new RequestHandler(this, client);
258258

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

261261
playerProfile.updateProfile();
262262

263263
ServerRequest downloadConfigRequest = new ServerRequest(RequestType.DOWNLOAD_REMOTE_CONFIG_VERSION,
264264
CommonRequests.getDownloadRemoteConfigVersionMessageRequest(this));
265-
getRequestHandler().sendServerRequests(downloadConfigRequest, true);
265+
requestHandler.sendServerRequests(downloadConfigRequest, true);
266266
getAssetDigest();
267267

268268
try {
@@ -278,14 +278,14 @@ private void initialize() throws RequestFailedException {
278278

279279
try {
280280
LevelUpRewardsMessage rewardsMessage = LevelUpRewardsMessage.newBuilder()
281-
.setLevel(playerProfile.getLevel())
281+
.setLevel(playerProfile.getStats().getLevel())
282282
.build();
283283
ServerRequest request = new ServerRequest(RequestType.LEVEL_UP_REWARDS, rewardsMessage);
284284
ServerRequestEnvelope envelope = ServerRequestEnvelope.createCommons(request, this);
285-
getRequestHandler().sendServerRequests(envelope);
285+
requestHandler.sendServerRequests(envelope);
286286
LevelUpRewardsResponse levelUpRewardsResponse = LevelUpRewardsResponse.parseFrom(request.getData());
287287
if (levelUpRewardsResponse.getResult() == Result.SUCCESS) {
288-
inventories.getItemBag().addAwardedItems(levelUpRewardsResponse);
288+
inventories.itemBag.addAwardedItems(levelUpRewardsResponse);
289289
}
290290
} catch (InvalidProtocolBufferException e) {
291291
throw new RequestFailedException(e);
@@ -295,7 +295,7 @@ private void initialize() throws RequestFailedException {
295295
ServerRequestEnvelope envelope = ServerRequestEnvelope.create();
296296
envelope.addPlatform(new ServerPlatformRequest(PlatformRequestType.GET_STORE_ITEMS, getStoreItems));
297297

298-
getRequestHandler().sendServerRequests(envelope);
298+
requestHandler.sendServerRequests(envelope);
299299

300300
List<LoginListener> loginListeners = getListeners(LoginListener.class);
301301

@@ -322,7 +322,7 @@ private void initialize() throws RequestFailedException {
322322
playerProfile.encounterTutorialComplete();
323323
}
324324

325-
int remainingCodenameClaims = getPlayerProfile().getPlayerData().getRemainingCodenameClaims();
325+
int remainingCodenameClaims = playerProfile.getPlayerData().getRemainingCodenameClaims();
326326
if (!tutorialStates.contains(TutorialState.NAME_SELECTION) && remainingCodenameClaims > 0) {
327327
playerProfile.claimCodeName();
328328
}
@@ -340,7 +340,7 @@ private void initialize() throws RequestFailedException {
340340
public void getAssetDigest() throws RequestFailedException {
341341
GetAssetDigestMessage message = CommonRequests.getGetAssetDigestMessageRequest(this);
342342
ServerRequest request = new ServerRequest(RequestType.GET_ASSET_DIGEST, message);
343-
getRequestHandler().sendServerRequests(request, true);
343+
requestHandler.sendServerRequests(request, true);
344344
}
345345

346346
/**
@@ -395,13 +395,13 @@ public void setLocation(double latitude, double longitude, double altitude) {
395395
public void setLocation(double latitude, double longitude, double altitude, double accuracy) {
396396
setLatitude(latitude);
397397
setLongitude(longitude);
398-
setAltitude(altitude);
399-
setAccuracy(accuracy);
398+
//setAltitude(altitude);
399+
//setAccuracy(accuracy);
400400
}
401401

402-
public long currentTimeMillis() {
403-
return time.currentTimeMillis();
404-
}
402+
public long currentTimeMillis() {
403+
return time.currentTimeMillis();
404+
}
405405

406406
/**
407407
* Validates and sets a given latitude value
@@ -486,7 +486,7 @@ public SignatureOuterClass.Signature.DeviceInfo getDeviceInfo() {
486486
* @return the sensor info
487487
*/
488488
public SignatureOuterClass.Signature.SensorInfo getSensorSignature(long currentTime, Random random) {
489-
if (this.sensorInfo == null || sensorInfo.getTimestampCreate() != 0L) {
489+
if (this.sensorInfo == null || sensorInfo.timestampCreate != 0L) {
490490
return SensorInfo.getDefault(this, currentTime, random);
491491
}
492492
return sensorInfo.getSensorInfo();
@@ -620,7 +620,7 @@ public boolean verifyChallenge(String token) throws RequestFailedException {
620620
hasChallenge = false;
621621
VerifyChallengeMessage message = VerifyChallengeMessage.newBuilder().setToken(token).build();
622622
ServerRequest request = new ServerRequest(RequestType.VERIFY_CHALLENGE, message);
623-
ByteString responseData = getRequestHandler().sendServerRequests(request, true);
623+
ByteString responseData = requestHandler.sendServerRequests(request, true);
624624
try {
625625
VerifyChallengeResponse response = VerifyChallengeResponse.parseFrom(responseData);
626626
hasChallenge = !response.getSuccess();
@@ -648,7 +648,7 @@ public String checkChallenge() throws RequestFailedException {
648648
CheckChallengeMessage message = CheckChallengeMessage.newBuilder().build();
649649
try {
650650
ServerRequest request = new ServerRequest(RequestType.CHECK_CHALLENGE, message);
651-
ByteString responseData = getRequestHandler().sendServerRequests(request, false);
651+
ByteString responseData = requestHandler.sendServerRequests(request, false);
652652
CheckChallengeResponse response = CheckChallengeResponse.parseFrom(responseData);
653653
String newChallenge = response.getChallengeUrl();
654654
if (response.getShowChallenge() && newChallenge != null && newChallenge.length() > 0) {
@@ -665,7 +665,7 @@ public String checkChallenge() throws RequestFailedException {
665665
* @return the current player position in Point form
666666
*/
667667
public Point getPoint() {
668-
return new Point(this.getLatitude(), this.getLongitude());
668+
return new Point(this.latitude, this.longitude);
669669
}
670670

671671
/**

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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 14 additions & 14 deletions
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

Lines changed: 8 additions & 8 deletions
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)