54
54
import com .pokegoapi .main .ServerRequest ;
55
55
import com .pokegoapi .util .DummyFuture ;
56
56
import com .pokegoapi .util .FutureWrapper ;
57
+ import com .pokegoapi .util .MapUtil ;
57
58
import com .pokegoapi .util .PokemonFuture ;
58
59
59
60
import java .util .ArrayList ;
@@ -122,6 +123,19 @@ public List<CatchablePokemon> getCatchablePokemon() throws LoginFailedException,
122
123
return getCatchablePokemonAsync ().toBlocking ();
123
124
}
124
125
126
+ /**
127
+ * Gets catchable pokemon sort by distance.
128
+ *
129
+ * @return the catchable pokemon sort
130
+ * @throws LoginFailedException the login failed exception
131
+ * @throws RemoteServerException the remote server exception
132
+ */
133
+ public java .util .Map <Double , CatchablePokemon > getCatchablePokemonSort ()
134
+ throws LoginFailedException , RemoteServerException {
135
+ MapUtil <CatchablePokemon > util = new MapUtil <>();
136
+ return util .sortItems (getCatchablePokemon (), api );
137
+ }
138
+
125
139
/**
126
140
* Returns a list of nearby pokemon (non-catchable).
127
141
*
@@ -147,8 +161,8 @@ protected List<NearbyPokemon> handle(MapObjects result) throws RemoteServerExcep
147
161
* Returns a list of nearby pokemon (non-catchable).
148
162
*
149
163
* @return a List of NearbyPokemon at your current location
150
- * @throws LoginFailedException if the login failed
151
- * @throws RemoteServerException When a buffer exception is thrown
164
+ * @throws LoginFailedException if the login failed
165
+ * @throws RemoteServerException When a buffer exception is thrown
152
166
*/
153
167
public List <NearbyPokemon > getNearbyPokemon () throws LoginFailedException , RemoteServerException {
154
168
return getNearbyPokemonAsync ().toBlocking ();
@@ -178,8 +192,8 @@ protected List<Point> handle(MapObjects result) throws RemoteServerException {
178
192
* Returns a list of spawn points.
179
193
*
180
194
* @return list of spawn points
181
- * @throws LoginFailedException if the login failed
182
- * @throws RemoteServerException When a buffer exception is thrown
195
+ * @throws LoginFailedException if the login failed
196
+ * @throws RemoteServerException When a buffer exception is thrown
183
197
*/
184
198
public List <Point > getSpawnPoints () throws LoginFailedException , RemoteServerException {
185
199
return getSpawnPointsAsync ().toBlocking ();
@@ -214,6 +228,18 @@ public List<Gym> getGyms() throws LoginFailedException, RemoteServerException {
214
228
return getGymsAsync ().toBlocking ();
215
229
}
216
230
231
+ /**
232
+ * Gets gym sort by distance.
233
+ *
234
+ * @return the gym sort
235
+ * @throws LoginFailedException the login failed exception
236
+ * @throws RemoteServerException the remote server exception
237
+ */
238
+ public java .util .Map <Double , Gym > getGymSort () throws LoginFailedException , RemoteServerException {
239
+ MapUtil <Gym > util = new MapUtil <>();
240
+ return util .sortItems (getGyms (), api );
241
+ }
242
+
217
243
/**
218
244
* Returns a list of decimated spawn points at current location.
219
245
*
@@ -237,13 +263,26 @@ protected List<Point> handle(MapObjects result) throws RemoteServerException {
237
263
* Returns a list of decimated spawn points at current location.
238
264
*
239
265
* @return list of spawn points
240
- * @throws LoginFailedException if the login failed
241
- * @throws RemoteServerException When a buffer exception is thrown
266
+ * @throws LoginFailedException if the login failed
267
+ * @throws RemoteServerException When a buffer exception is thrown
242
268
*/
243
269
public List <Point > getDecimatedSpawnPoints () throws LoginFailedException , RemoteServerException {
244
270
return getDecimatedSpawnPointsAsync ().toBlocking ();
245
271
}
246
272
273
+
274
+ /**
275
+ * Gets decimated spawn points sort by distance.
276
+ *
277
+ * @return the decimated spawn points sort
278
+ * @throws LoginFailedException the login failed exception
279
+ * @throws RemoteServerException the remote server exception
280
+ */
281
+ public java .util .Map <Double , Point > getDecimatedSpawnPointsSort () throws LoginFailedException , RemoteServerException {
282
+ MapUtil <Point > util = new MapUtil <>();
283
+ return util .sortItems (getDecimatedSpawnPoints (), api );
284
+ }
285
+
247
286
/**
248
287
* Returns MapObjects around your current location.
249
288
*
@@ -271,7 +310,7 @@ public PokemonFuture<MapObjects> getMapObjectsAsync(int width) {
271
310
*/
272
311
public PokemonFuture <MapObjects > getMapObjectsAsync (List <Long > cellIds ) {
273
312
274
- if ( (api .currentTimeMillis () - lastMapUpdate ) < RESEND_REQUEST ) {
313
+ if ((api .currentTimeMillis () - lastMapUpdate ) < RESEND_REQUEST ) {
275
314
return new DummyFuture <MapObjects >(cachedMapObjects );
276
315
}
277
316
@@ -322,7 +361,6 @@ public FortType apply(FortData fortData) {
322
361
}
323
362
324
363
325
-
326
364
return result ;
327
365
}
328
366
};
@@ -332,8 +370,8 @@ public FortType apply(FortData fortData) {
332
370
* Returns MapObjects around your current location.
333
371
*
334
372
* @return MapObjects at your current location
335
- * @throws LoginFailedException if the login failed
336
- * @throws RemoteServerException When a buffer exception is thrown
373
+ * @throws LoginFailedException if the login failed
374
+ * @throws RemoteServerException When a buffer exception is thrown
337
375
*/
338
376
public MapObjects getMapObjects () throws LoginFailedException , RemoteServerException {
339
377
return getMapObjectsAsync ().toBlocking ();
@@ -344,9 +382,8 @@ public MapObjects getMapObjects() throws LoginFailedException, RemoteServerExcep
344
382
*
345
383
* @param width width
346
384
* @return MapObjects at your current location
347
- *
348
- * @throws LoginFailedException If login fails.
349
- * @throws RemoteServerException If request errors occurred.
385
+ * @throws LoginFailedException If login fails.
386
+ * @throws RemoteServerException If request errors occurred.
350
387
*/
351
388
public MapObjects getMapObjects (int width ) throws LoginFailedException , RemoteServerException {
352
389
return getMapObjectsAsync (width ).toBlocking ();
@@ -358,8 +395,8 @@ public MapObjects getMapObjects(int width) throws LoginFailedException, RemoteSe
358
395
* @param latitude latitude
359
396
* @param longitude longitude
360
397
* @return MapObjects in the given cells
361
- * @throws LoginFailedException if the login failed
362
- * @throws RemoteServerException When a buffer exception is thrown
398
+ * @throws LoginFailedException if the login failed
399
+ * @throws RemoteServerException When a buffer exception is thrown
363
400
*/
364
401
@ Deprecated
365
402
public MapObjects getMapObjects (double latitude , double longitude )
@@ -374,8 +411,8 @@ public MapObjects getMapObjects(double latitude, double longitude)
374
411
* @param latitude latitude
375
412
* @param longitude longitude
376
413
* @return MapObjects in the given cells
377
- * @throws LoginFailedException if the login failed
378
- * @throws RemoteServerException When a buffer exception is thrown
414
+ * @throws LoginFailedException if the login failed
415
+ * @throws RemoteServerException When a buffer exception is thrown
379
416
*/
380
417
@ Deprecated
381
418
public MapObjects getMapObjects (List <Long > cellIds , double latitude , double longitude )
@@ -390,8 +427,8 @@ public MapObjects getMapObjects(List<Long> cellIds, double latitude, double long
390
427
* @param longitude longitude
391
428
* @param width width
392
429
* @return MapObjects in the given cells
393
- * @throws LoginFailedException if the login failed
394
- * @throws RemoteServerException When a buffer exception is thrown
430
+ * @throws LoginFailedException if the login failed
431
+ * @throws RemoteServerException When a buffer exception is thrown
395
432
*/
396
433
@ Deprecated
397
434
public MapObjects getMapObjects (double latitude , double longitude , int width )
@@ -405,10 +442,10 @@ public MapObjects getMapObjects(double latitude, double longitude, int width)
405
442
* @param cellIds cellIds
406
443
* @param latitude latitude
407
444
* @param longitude longitude
408
- * @param altitude altitude
445
+ * @param altitude altitude
409
446
* @return MapObjects in the given cells
410
- * @throws LoginFailedException if the login failed
411
- * @throws RemoteServerException When a buffer exception is thrown
447
+ * @throws LoginFailedException if the login failed
448
+ * @throws RemoteServerException When a buffer exception is thrown
412
449
*/
413
450
@ Deprecated
414
451
public MapObjects getMapObjects (List <Long > cellIds , double latitude , double longitude , double altitude )
@@ -424,8 +461,8 @@ public MapObjects getMapObjects(List<Long> cellIds, double latitude, double long
424
461
*
425
462
* @param cellIds List of cellId
426
463
* @return MapObjects in the given cells
427
- * @throws LoginFailedException if the login failed
428
- * @throws RemoteServerException When a buffer exception is thrown
464
+ * @throws LoginFailedException if the login failed
465
+ * @throws RemoteServerException When a buffer exception is thrown
429
466
*/
430
467
public MapObjects getMapObjects (List <Long > cellIds ) throws LoginFailedException , RemoteServerException {
431
468
return getMapObjectsAsync (cellIds ).toBlocking ();
0 commit comments