pokedex-java-api is the first wrapper for pokeapi.co written in pure Java.
- Fully documented
- Everything is treated as an object
- Mantainable and readable code
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.iAmGio</groupId>
<artifactId>pokedex-java-api</artifactId>
<version>VERSION</version>
</dependency>
</dependencies>
repositories {
maven {
url 'https://jitpack.io'
}
}
dependencies {
implementation 'com.github.iAmGio:pokedex-java-api:VERSION'
}
JAR files can be found in the releases tab.
To get started, let's try to get the types of Bulbasaur:
public class Main {
public static void main(String[] args) {
Pokemon bulbasaur = Pokemon.fromName("bulbasaur");
Pair<PokemonType, PokemonType> types = bulbasaur.getTypes();
System.out.println(types.getFirst());
System.out.println(types.getSecond());
}
}
This will output:
GRASS
POISON
Every component of the API (such as Pokémons, abilities, etc) can be instantiated by using two static methods: fromName
, which takes the name as a string, and fromId
, which takes the identifier as a number.
An interesting part of this library is the one which collects strings from various languages, contained inside the lang package.
Every localized string is composed by two fields: name
(String) and language
(enum Language), and groups of them are stored inside specific lists, such as LocalizedNames
or FlavorList
(both extend LocalizedNameList
). They have a get(Language)
method which returns the string in the selected language.
The particular one is FlavorList
: a flavor is a localized string assigned within a version (or a version group) of the official game: having a flavor list, you will be able to do something like this:
FlavorList<Version> flavors = ...;
String englishStringFromPearl = flavors.filterVersion(Version.PEARL).get(Language.ENGLISH);
Credits to this project and to pokeapi.co are appreciated.