Skip to content

Commit

Permalink
Merge branch 'master' into Development (#424)
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
Grover-c13 authored Aug 1, 2016
1 parent 8e8b939 commit d1cd3f9
Show file tree
Hide file tree
Showing 98 changed files with 16,996 additions and 1,156 deletions.
136 changes: 102 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
Pokemon GO Java API

[![Build Status](https://travis-ci.org/Grover-c13/PokeGOAPI-Java.svg?branch=master)](https://travis-ci.org/Grover-c13/PokeGOAPI-Java)
[![](https://jitpack.io/v/Grover-c13/PokeGOAPI-Java.svg)](https://jitpack.io/#Grover-c13/PokeGOAPI-Java)

Javadocs : [CLICK ME](https://jitpack.io/com/github/Grover-c13/PokeGOAPI-Java/a2828da60d/javadoc/)

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

___
:exclamation:

This API may seem unstable. This is because the backend Pokemon GO servers are unstable.
:exclamation: :exclamation: :exclamation:

In case stuff is not working as expected, wait a moment to see if the problem resolves itself automatically.
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).

You may also check the status of the servers on [IsPokemonGoDownOrNot.com](http://ispokemongodownornot.com) or [MMOServerStatus.com](http://www.mmoserverstatus.com/pokemon_go).
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.

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).
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).

:exclamation:
:exclamation: :exclamation: :exclamation:
___

# Build
- Clone the repo and cd into the folder
- `` git submodule update --init ``
- compile and package
- `` ./gradlew build bundle ``
- you should have the api bundled in ``build/libs/PokeGOAPI-Java_bundle-0.0.1-SNAPSHOT.jar``
# How to import

Import from Maven/Gradle/SBT/Leiningen using JitPack : [![](https://jitpack.io/v/Grover-c13/PokeGOAPI-Java.svg)](https://jitpack.io/#Grover-c13/PokeGOAPI-Java)

After you clicked on this link, jitpack will show you multiple build (try use the latest one since the api grow everyday).
JitPack will show an example for each dependency manager to include our API into your project.

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
OR

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

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

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

EG:
# Usage exemple (mostly how to login) :
```java
OkHttpClient httpClient = new OkHttpClient();
//Use Google
//First Ever Login. Persist info when you recieve callback
PokemonGo go = new PokemonGo(new GoogleCredentialProvider(httpClient,listner),httpClient);
//Subsequently
PokemonGo go = new PokemonGo(new GoogleCredentialProvider(httpClient,refreshToken),httpClient);
//Or use PTC

/**
* Google:
* You will need to redirect your user to GoogleUserCredentialProvider.LOGIN_URL
* Afer this, the user must signin on google and get the token that will be show to him.
* This token will need to be put as argument to login.
*/
GoogleUserCredentialProvider provider = new GoogleUserCredentialProvider(http);

// in this url, you will get a code for the google account that is logged
System.out.println("Please go to " + GoogleUserCredentialProvider.LOGIN_URL);
System.out.println("Enter authorisation code:");

// Ask the user to enter it in the standart input
Scanner sc = new Scanner(System.in);
String access = sc.nextLine();

// we should be able to login with this token
provider.login(access);
PokemonGo go = new PokemonGo(provider, httpClient);

/**
* After this, if you do not want to re-authorize the google account every time,
* you will need to store the refresh_token that you can get the first time with provider.getRefreshToken()
* ! The API does not store the refresh token for you !
* log in using the refresh token like this :
*/
PokemonGo go = new PokemonGo(new GoogleUserCredentialProvider(httpClient, refreshToken), httpClient);

/**
* PTC is much simpler, but less secure.
* You will need the username and password for each user log in
* This account does not currently support a refresh_token.
* Example log in :
*/
PokemonGo go = new PokemonGo(new PtcCredentialProvider(httpClient,username,password),httpClient);
Log.v(go.getPlayerProfile());

// After this you can access the api from the PokemonGo instance :
go.getPlayerProfile(); // to get the user profile
go.getInventories(); // to get all his inventories (Pokemon, backpack, egg, incubator)
go.setLocation(lat, long, alt); // set your position to get stuff around (altitude is not needed, you can use 1 for example)
go.getMap().getCatchablePokemon(); // get all currently Catchable Pokemon around you

// If you want to go deeper, you can directly send your request with our RequestHandler
// For example, here we are sending a request to get the award for our level
// This applies to any method defined in the protos file as Request/Response)

LevelUpRewardsMessage msg = LevelUpRewardsMessage.newBuilder().setLevel(yourLVL).build();
ServerRequest serverRequest = new ServerRequest(RequestType.LEVEL_UP_REWARDS, msg);
go.getRequestHandler().sendServerRequests(serverRequest);

// and get the response like this :

LevelUpRewardsResponse response = null;
try {
response = LevelUpRewardsResponse.parseFrom(serverRequest.getData());
} catch (InvalidProtocolBufferException e) {
// its possible that the parsing fail when servers are in high load for example.
throw new RemoteServerException(e);
}
```

##Android Dev FAQ

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

## Contributors
- Grover-c13
- jabbink
- Aphoh
- zeladada
- darakath
- vmarchaud

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)
- @Grover-c13
- @jabbink
- @Aphoh
- @mjmfighter
- @vmarchaud
- @langerhans

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/))
27 changes: 19 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ buildscript {
dependencies {
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.7.7'
}


}

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

repositories {
mavenCentral()
maven { url "https://jitpack.io" }
}

sourceSets {
Expand All @@ -39,13 +38,11 @@ sourceSets {

// Remove all .proto definition from the final build
processResources {
exclude('**/*')
exclude('POGOProtos/')
}

// Run this task to bundle all needed dependency
task bundle(type: Jar) {
baseName = project.name + '_bundle'

from {
configurations.compile.collect {
it.isDirectory() && !it.isEmpty() ? it : zipTree(it)
Expand All @@ -54,6 +51,8 @@ task bundle(type: Jar) {
with jar
}

jar.finalizedBy(bundle)

protobuf {
// Configure the protoc executable
protoc {
Expand Down Expand Up @@ -90,11 +89,15 @@ checkstyle {
checkstyleMain.doLast {
def outputFile = file(checkstyleOutputDir + "main.xml")
if (outputFile.exists() && outputFile.text.contains("<error ")) {
throw new GradleException("There were checkstyle warnings! For more info check $outputFile")
logger.warn("!!!!-----------------------------------!!!!")
logger.warn("There were checkstyle warnings! For more info check $outputFile")
logger.warn("PLEASE CORRECT BEFORE SUBMITTING A PULLREQUEST")
logger.warn("!!!!-----------------------------------!!!!")
}
}

dependencies {
compile 'com.github.svarzee:gpsoauth-java:v0.3.0'
compile 'com.squareup.okio:okio:1.9.0'
compile 'com.squareup.moshi:moshi:1.2.0'
compile 'com.annimon:stream:1.1.1'
Expand All @@ -109,11 +112,19 @@ idea {
}
}

task sourcesJar(type: Jar) {
from sourceSets.main.java.srcDirs
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allJava
}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
javadoc.failOnError(false);
javadoc.source = sourceSets.main.allJava
from javadoc.destinationDir
}

artifacts {
archives sourcesJar
archives javadocJar
}
Loading

0 comments on commit d1cd3f9

Please sign in to comment.