Skip to content

Commit d1cd3f9

Browse files
authored
Merge branch 'master' into Development (#424)
* Refresh the OAuth token when it expires * Fix my siliness and provide API consumers a way to provide their refresh token when using static auth * add query from hatched eggs + rewrite stuff around EggPokemon * fix the explaination for eclipse user * Level enum public for custom loggers * Publish sources jar Fixes #128 * add license to GoogleLoginSecrets * Use a reset instead of using another instance * Fix the checkstyle config to not break other modules * find Pokemon by ID update inventory after hatching eggs add missing license * Meta info on pokemon * add method the incubator * fix typo * Add a callback for when the Initial oAuth completes so that the app can automate the flow * Power up pokemon API * Add info about native google sign in * REAME.md: fix Usefull->Useful typo * README.md: fix PtcLogin classname type * fix force updating inventories * Fix incorrect static statements on point * Added iv calculator (#207) * Added iv calculator * checkstyleMain fix * Fix @returns in doc of getIVRatio() * take care that the candies actually are in the map * forgot that cancerous check style * tweak checkstyle config to be friendly (#226) * Add cause to LoginFailedExceptions. (#220) Signed-off-by: Niklas Walter <[email protected]> * Remove printStackTrace from updateProfile (#221) updateProfile, in case of failure, would dump stacktraces to the console and then crash in the next line with a NullPointerException * Added request to add modifiers to forts, for example a lure-module on a pokestop (#217) * implemented request to add fort modifier * added @throws to javadoc for addModifier in Pokestop.java * Added SetFavoritePokemon method (#222) * add lombok to more objects (#212) * add lombok to more objects * add lombok to GoogleAuthJson * add lombok to Team * getItemsCount function (#224) * get total space used by items * get total space used by items * add javadoc * Rewrote and Refactored login logic. Now the credential providers transparently handle providing credentials and refreshing tokens. * Update the protobuf dependency (#235) Includes fix for hatched eggs IndexOutOfBoundsException * WIP: Gym/Battle (#203) * Add info about native google sign in * fix force updating inventories * REAME.md: fix Usefull->Useful typo * README.md: fix PtcLogin classname type * Start Gym + Battle API * Battle API - Example included, utility functions to get state of battle. Can only spam attack right now. * Deprecate pokemon.getFavorite, rename to pokemon.isFavorite (#230) * deprecate getFavorite, rename to isFavorite * Adhere to checkstyle * Use gradle-wrapper instead (#200) * Use gradle-wrapper instead * Changed second gradle usage to use gradlew aswell * Fix typos (#218) * Fix UTF-8 encoding * Fix typo recieved -> received * fix example * Consistently use RemoteServerException for network/server errors (#243) * Redone meta pm, lots of info available, several enums for pokemon (some may be duplicates of proto enums), fix catchable pokemon (#246) * fix #237 + #227 (#240) * Update protobufs to latest version * Add getPoints() to gym wrapper (#247) * Fix #171 - Implement logging levels * Hypno should actually be in FAMILY_DROWZEE (#262) * Update README.md (#257) Clarification on what the function calls do. If we're going to change the API wrapper, we should at least briefly comment on how it works underneath. * added the ability to use potions & revive on pokemon (#236) * inizio pozioni pokemon * inizio pozioni pokemon * fixed space * checkstyle fixes * refresh pokemon stamina after heal/revive * added a request to accept level up rewards and unlocks (#259) * Fix silly error * Rewrite readme with all new stuff - explain the risk of using this api - more examples - got to jitpack to build with maven/graddle - update contributor * abstract time behavior to allow mocking and replacing the time by non-System time (#277) * set time implementation correctly (#282) make old PtcCredentialProvider constructor @deprecated * settings via DownloadSettings + protobuf update (#285) * inizio pozioni pokemon * inizio pozioni pokemon * fixed space * checkstyle fixes * refresh pokemon stamina after heal/revive * add support for settings * add support for settings * Added CP based calculations (#272) * Added CP based calculations * Implemented method instead of lookup * Added check if meta info exists. Swapped map * #272 (comment) * Add usage instructions for Eclipse users (#290) Many will opt for simply copying the lib to the libs folder, but this allows building the API project as necessary, while maintaining an updated version of the lib produced in the target project. ** Intended for only building the target project with Eclipse ** * fix for #279 (#292) * check and equip badges * check and equip badges * Automatic google login with username and password (#265) * Add gpsoauth dependency * Add google auto credentials provider * Add token refresh * svarzee-Development (#297) * Add gpsoauth dependency * Add google auto credentials provider * Add token refresh * Checkstyle will not stop you building now, but you are still expected to correct issues before submitting a PR. (#300) * Checkstyle will not stop you building now, but you are still expected to correct issues before submitting a PR. fixed issue with checkstyle in google auto login. * Checkstyle fix * gdev (#305) * Checkstyle will not stop you building now, but you are still expected to correct issues before submitting a PR. fixed issue with checkstyle in google auto login. * Checkstyle fix * Added time to new provider * added time * added PokemonMoveMeta + Registry (#298) * created PokemonMoveMeta.java * added PokemonMoveMetaRegistry * Update PokemonType.java * modify build process to generate javadoc and one bundled jar + fix checkstyle (#307) * add javadoc link to readme * Added weight getter to Pokemon.java (#309) * trigger bundle after creating the jar * bundle is done for every build now * Added new oauth for google user interaction to supercede GoogleCredentialProvider (example included) added a new hasLure method to Pokestops that is more reliable. Undeprecrated constructors that construct time objects by default (#316) * delete old google token provider since its working + add explain on example * Correct, organize, and format README - Correct spelling, grammar, and punctuation errors - Format lists into individual steps - Break comments into smaller segments - Simplify complex explanations * fix styles * Update the readme example to use the latest google provider * add javadoc * added getter to get refresh token for GoogleAutoProvider + constructor without Time impl in GoogleUserProvider * Feature request Issue 311 * - replaced for loop by iterator because of concurrent modification in MapObjects Update method * update readme with slack invitation link * hotfix spamming request when constructing PokemonGo instance * test * test * -also changed update method of gyms to use iterator * Upgrade gpsoauth * - fixed styling * Cleaned up some doc blocks (#352) * Added Util class to get Name for Pokedex Numbers, Also added Translations (#284) * Added Util class to get NAme for Pokedex Numbers, Also added Translations for those * Adjusted Files According to Pullrequest Review * Removed Double License Headeer, Added Missing License Header * Fixed hasLurePokemon() from always returning false unless the lure module expired and the pokestop was still in memory with a pokemon. It now properly returns true if there is a pokemon at the pokestop and the lure is not expired. * Async implementation based in Futures (#360) * Base for async * Transparent async requests * Converted map * Converted map, may have broken cache * Cleanup leftovers of Rx * Start on catchable pokemon * Did some methods on CatchablePokemon. Implemented NestedFutureWrapper to link Futures * Switched Pokestop * Some tinkering with timings and forgetting to clear lists * Exceptions shoudl accept Throwable * Cleanup of deprecate methods, Removed sleeps * Fixed sending garbage * Actually got it working * Checkstyle update * Checkstyle update * Upped timer a bit because of a few issues with empty requests * Sync list (#370) * Add moves to pokemon meta registry (#368) * Fix get catchablePokemon (#386) * Sync list * Hopefully fix map.getObject/getCatchablePokemon issue * Make constructor lightweight (#388) * Sync list * Hopefully fix map.getObject/getCatchablePokemon issue * Refactor some player profile stuff, make the constructor shorter, made it lazy init (wont call for an update on the server unless you call a method to get data) * The api constructor will not make any server requests, it will lazy load any sections of the api a person needs (ie callling getInventories will get stuff from the server if its yet to happen). Some extra methods now throw RemoteServer/Login exceptions so please keep that in mind. cleaned up a few things (mainly javadoc). * Refactor some player profile stuff, make the constructor shorter, made it lazy init (wont call for an update on the server unless you call a method to get data) * Implemented inventory settings (#376) * added support for incense activation (#314) * Changed private fields to protected to allow extending of the Providers for API users without having to rewrite the whole class. (#350) * Optimize imports (#390) * Optimize imports * Optimize imports * added Japanese pokemon names and fixed garbled characters in Russian and Chinese (#383) * Fort details should be doubles instead of longs (#393) * #378 (#392) * Fix import.*, fix other checkstyle stuff, fix NPE when getting stats (#401) * Add evolution auxiliaries (#400) * fix infinite loop when pokemon flees using catch(), removed pokemon from catchable list after being caught/fleeing * fix infinite loop when pokemon flees using catch(), removed pokemon from catchable list after being caught/fleeing * catchfix (#404) * fix infinite loop when pokemon flees using catch(), removed pokemon from catchable list after being caught/fleeing * fix infinite loop when pokemon flees using catch(), removed pokemon from catchable list after being caught/fleeing * Lucky egg for spinnix yay * useLuckyEgg() in ItemBag for spinnix, Fix NPE on catch result Fix issue when pokemon broke out of ball Fix checkstyle issues * Remove print * Fixes an ArrayOutOfBoundsException (#411) Fixes an ArrayOutOfBoundsException in EvolutionInfo. Currently it takes the length of an array as an index in the array which will result in an exception being thrown anytime this function is called. * Extra log levels: all and none (#409) * Extra log levels: all and none * Fix indentation (tabs only) * Adding Sorting Map Objects (#396) * Adding map util to get distance between two points * Adding sorting function for objects in the map * Adding the check if the user have enough poke ball´s * Adding the check if the user have enough poke ball´s * Adding license * Fixing example class * Fix code style * Updating code style * Updating code style * Fixing import * luresfixesandgoodtimes (#418) * Added lured pokemon to getCatchablePokemon removed DummyFuture Fixed NPE in FutureWrapper when using .just Fixed issue when caught pokemon will still appearing in catchable pokemon Added a little more detail to the PTC login exception Changed exception message from "Error in url" to "Invalid auth status code recieved" * Checkstyle * Travis fix * updated moves (#416) https://www.reddit.com/r/TheSilphRoad/comments/4v99uo/move_powers_have_been_updated/ * Adding the check if the user have enough poke ball´s (#397) * Adding the check if the user have enough poke ball´s * Adding the check if the user have enough poke ball´s * Fixing example class * Fix code style * updating submodule to latest (#419)
1 parent 8e8b939 commit d1cd3f9

File tree

98 files changed

+16996
-1156
lines changed

Some content is hidden

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

98 files changed

+16996
-1156
lines changed

README.md

+102-34
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
Pokemon GO Java API
44

55
[![Build Status](https://travis-ci.org/Grover-c13/PokeGOAPI-Java.svg?branch=master)](https://travis-ci.org/Grover-c13/PokeGOAPI-Java)
6+
[![](https://jitpack.io/v/Grover-c13/PokeGOAPI-Java.svg)](https://jitpack.io/#Grover-c13/PokeGOAPI-Java)
7+
8+
Javadocs : [CLICK ME](https://jitpack.io/com/github/Grover-c13/PokeGOAPI-Java/a2828da60d/javadoc/)
69

710
See this guide for adding functionality:
811
https://docs.google.com/document/d/1BE8O6Z19sQ54T5T7QauXgA11GbL6D9vx9AAMCM5KlRA
@@ -11,47 +14,112 @@ See this spreadsheet for RPC endpoints and progress :
1114
https://docs.google.com/spreadsheets/d/1Xv0Gw5PzIRaVou2xrl6r7qySrcmOKjQWLBjJA73YnJM
1215

1316
___
14-
:exclamation:
15-
16-
This API may seem unstable. This is because the backend Pokemon GO servers are unstable.
17+
:exclamation: :exclamation: :exclamation:
1718

18-
In case stuff is not working as expected, wait a moment to see if the problem resolves itself automatically.
19+
This API may have issues when the PokemonGO servers are under high load or down, in this case please wait for the official to get back up. You can check the official servers status on [IsPokemonGoDownOrNot.com](http://ispokemongodownornot.com) or [MMOServerStatus.com](http://www.mmoserverstatus.com/pokemon_go).
1920

20-
You may also check the status of the servers on [IsPokemonGoDownOrNot.com](http://ispokemongodownornot.com) or [MMOServerStatus.com](http://www.mmoserverstatus.com/pokemon_go).
21+
This API doesnt fake the official client perfectly, niantic may know that you arent using the official app, we encourage you to use a alternate account to play with this API.
2122

22-
If you just want to use it, wait some days until the server issues are resolved (or if there is a problem with this library, you may fix it and send a PR this way).
23+
If you are using this lib to catch pokemon and loot pokestop, take care that you arent teleporting, the servers may issue a softban against your client (its temporary, between 10 and 30 minutes in general).
2324

24-
:exclamation:
25+
:exclamation: :exclamation: :exclamation:
2526
___
2627

27-
# Build
28-
- Clone the repo and cd into the folder
29-
- `` git submodule update --init ``
30-
- compile and package
31-
- `` ./gradlew build bundle ``
32-
- you should have the api bundled in ``build/libs/PokeGOAPI-Java_bundle-0.0.1-SNAPSHOT.jar``
28+
# How to import
29+
30+
Import from Maven/Gradle/SBT/Leiningen using JitPack : [![](https://jitpack.io/v/Grover-c13/PokeGOAPI-Java.svg)](https://jitpack.io/#Grover-c13/PokeGOAPI-Java)
31+
32+
After you clicked on this link, jitpack will show you multiple build (try use the latest one since the api grow everyday).
33+
JitPack will show an example for each dependency manager to include our API into your project.
3334

34-
PS : To Eclipse user, you must build once : `` ./gradlew build `` and add the generated java class for proto into eclipse source path : Right click on the project > Build path > Configure Build Path > Source > Add Folder > Select `build/generated/source/proto/main/java` > Finish
35+
OR
3536

36-
# Usage
37-
Include the API as jar from your own build, or use Maven/Gradle/SBT/Leiningen: https://jitpack.io/#Grover-c13/PokeGOAPI-Java/master-SNAPSHOT
37+
Import JAR in Eclipse
38+
- Right click on the project
39+
- Select Build path > Java Build Path
40+
- Select Libraries tab
41+
- Select Add External JARs…
42+
- Select `PokeGOAPI-Java/build/libs/PokeGOAPI-Java-0.0.1-SNAPSHOT.jar`
43+
- Finish
3844

39-
Mostly everything is accessed through the PokemonGo class in the API package.
45+
# Build from source
46+
- Clone the repo and cd into the folder
47+
- `` git submodule update --init ``
48+
- `` ./gradlew build ``
49+
- you should have the api jar in ``build/libs/PokeGOAPI-Java-0.0.1-SNAPSHOT.jar``
4050

41-
The constructor of PokemonGo class requires a AuthInfo object which can be obtained from GoogleLogin().login or PtcLogin().login, and a OkHttpClient object.
51+
PS : for users who want to import the api into Eclipse IDE, you'll need to :
52+
- build once : `` ./gradlew build ``
53+
- Right click on the project
54+
- Select Build path > Configure Build Path > Source > Add Folder
55+
- Select `build/generated/source/proto/main/java`
56+
- Finish
4257

43-
EG:
58+
# Usage exemple (mostly how to login) :
4459
```java
4560
OkHttpClient httpClient = new OkHttpClient();
46-
//Use Google
47-
//First Ever Login. Persist info when you recieve callback
48-
PokemonGo go = new PokemonGo(new GoogleCredentialProvider(httpClient,listner),httpClient);
49-
//Subsequently
50-
PokemonGo go = new PokemonGo(new GoogleCredentialProvider(httpClient,refreshToken),httpClient);
51-
//Or use PTC
61+
62+
/**
63+
* Google:
64+
* You will need to redirect your user to GoogleUserCredentialProvider.LOGIN_URL
65+
* Afer this, the user must signin on google and get the token that will be show to him.
66+
* This token will need to be put as argument to login.
67+
*/
68+
GoogleUserCredentialProvider provider = new GoogleUserCredentialProvider(http);
69+
70+
// in this url, you will get a code for the google account that is logged
71+
System.out.println("Please go to " + GoogleUserCredentialProvider.LOGIN_URL);
72+
System.out.println("Enter authorisation code:");
73+
74+
// Ask the user to enter it in the standart input
75+
Scanner sc = new Scanner(System.in);
76+
String access = sc.nextLine();
77+
78+
// we should be able to login with this token
79+
provider.login(access);
80+
PokemonGo go = new PokemonGo(provider, httpClient);
81+
82+
/**
83+
* After this, if you do not want to re-authorize the google account every time,
84+
* you will need to store the refresh_token that you can get the first time with provider.getRefreshToken()
85+
* ! The API does not store the refresh token for you !
86+
* log in using the refresh token like this :
87+
*/
88+
PokemonGo go = new PokemonGo(new GoogleUserCredentialProvider(httpClient, refreshToken), httpClient);
89+
90+
/**
91+
* PTC is much simpler, but less secure.
92+
* You will need the username and password for each user log in
93+
* This account does not currently support a refresh_token.
94+
* Example log in :
95+
*/
5296
PokemonGo go = new PokemonGo(new PtcCredentialProvider(httpClient,username,password),httpClient);
53-
Log.v(go.getPlayerProfile());
97+
98+
// After this you can access the api from the PokemonGo instance :
99+
go.getPlayerProfile(); // to get the user profile
100+
go.getInventories(); // to get all his inventories (Pokemon, backpack, egg, incubator)
101+
go.setLocation(lat, long, alt); // set your position to get stuff around (altitude is not needed, you can use 1 for example)
102+
go.getMap().getCatchablePokemon(); // get all currently Catchable Pokemon around you
103+
104+
// If you want to go deeper, you can directly send your request with our RequestHandler
105+
// For example, here we are sending a request to get the award for our level
106+
// This applies to any method defined in the protos file as Request/Response)
107+
108+
LevelUpRewardsMessage msg = LevelUpRewardsMessage.newBuilder().setLevel(yourLVL).build();
109+
ServerRequest serverRequest = new ServerRequest(RequestType.LEVEL_UP_REWARDS, msg);
110+
go.getRequestHandler().sendServerRequests(serverRequest);
111+
112+
// and get the response like this :
113+
114+
LevelUpRewardsResponse response = null;
115+
try {
116+
response = LevelUpRewardsResponse.parseFrom(serverRequest.getData());
117+
} catch (InvalidProtocolBufferException e) {
118+
// its possible that the parsing fail when servers are in high load for example.
119+
throw new RemoteServerException(e);
120+
}
54121
```
122+
55123
##Android Dev FAQ
56124

57125
- I can't use the sample code! It just throws a login exception!
@@ -75,11 +143,11 @@ You can't. The Google Identity Platform uses the SHA1 fingerprint and package na
75143
- Submit a pull request on the `Development` branch :D
76144

77145
## Contributors
78-
- Grover-c13
79-
- jabbink
80-
- Aphoh
81-
- zeladada
82-
- darakath
83-
- vmarchaud
84-
85-
You can join us in the slack channel #javaapi on the pkre.slack.com (you should get an invite by a bot posted somewhere in the subreddit /r/pokemongodev)
146+
- @Grover-c13
147+
- @jabbink
148+
- @Aphoh
149+
- @mjmfighter
150+
- @vmarchaud
151+
- @langerhans
152+
153+
You can join us in the slack channel #javaapi on the pkre.slack.com ([you can get invited here](https://shielded-earth-81203.herokuapp.com/))

build.gradle

+19-8
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ buildscript {
88
dependencies {
99
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.7.7'
1010
}
11-
12-
1311
}
1412

1513
apply plugin: 'idea'
@@ -25,6 +23,7 @@ targetCompatibility = 1.7
2523

2624
repositories {
2725
mavenCentral()
26+
maven { url "https://jitpack.io" }
2827
}
2928

3029
sourceSets {
@@ -39,13 +38,11 @@ sourceSets {
3938

4039
// Remove all .proto definition from the final build
4140
processResources {
42-
exclude('**/*')
41+
exclude('POGOProtos/')
4342
}
4443

4544
// Run this task to bundle all needed dependency
4645
task bundle(type: Jar) {
47-
baseName = project.name + '_bundle'
48-
4946
from {
5047
configurations.compile.collect {
5148
it.isDirectory() && !it.isEmpty() ? it : zipTree(it)
@@ -54,6 +51,8 @@ task bundle(type: Jar) {
5451
with jar
5552
}
5653

54+
jar.finalizedBy(bundle)
55+
5756
protobuf {
5857
// Configure the protoc executable
5958
protoc {
@@ -90,11 +89,15 @@ checkstyle {
9089
checkstyleMain.doLast {
9190
def outputFile = file(checkstyleOutputDir + "main.xml")
9291
if (outputFile.exists() && outputFile.text.contains("<error ")) {
93-
throw new GradleException("There were checkstyle warnings! For more info check $outputFile")
92+
logger.warn("!!!!-----------------------------------!!!!")
93+
logger.warn("There were checkstyle warnings! For more info check $outputFile")
94+
logger.warn("PLEASE CORRECT BEFORE SUBMITTING A PULLREQUEST")
95+
logger.warn("!!!!-----------------------------------!!!!")
9496
}
9597
}
9698

9799
dependencies {
100+
compile 'com.github.svarzee:gpsoauth-java:v0.3.0'
98101
compile 'com.squareup.okio:okio:1.9.0'
99102
compile 'com.squareup.moshi:moshi:1.2.0'
100103
compile 'com.annimon:stream:1.1.1'
@@ -109,11 +112,19 @@ idea {
109112
}
110113
}
111114

112-
task sourcesJar(type: Jar) {
113-
from sourceSets.main.java.srcDirs
115+
task sourcesJar(type: Jar, dependsOn: classes) {
114116
classifier = 'sources'
117+
from sourceSets.main.allJava
118+
}
119+
120+
task javadocJar(type: Jar, dependsOn: javadoc) {
121+
classifier = 'javadoc'
122+
javadoc.failOnError(false);
123+
javadoc.source = sourceSets.main.allJava
124+
from javadoc.destinationDir
115125
}
116126

117127
artifacts {
118128
archives sourcesJar
129+
archives javadocJar
119130
}

0 commit comments

Comments
 (0)