The Mojang API for Java is a library that provides Java developers with an easy-to-use interface for accessing Mojang's APIs. This library makes it simple to fetch game profiles and UUIDs from Mojang's servers, and cache them locally for faster access.
To get started with the Mojang API for Java, you can add it to your Maven or Gradle project as a dependency.
<repositories>
<repository>
<id>eldonexus-repo</id>
<url>https://eldonexus.de/repository/maven-public/</url>
</repository>
</repositories>
Then add the dependency:
<dependency>
<groupId>de.snowii</groupId>
<artifactId>mojang-api</artifactId>
<version>1.1.0</version>
</dependency>
Add the following repository to your build.gradle file:
repositories {
mavenCentral()
maven("https://eldonexus.de/repository/maven-public/")
}
Then add the dependency:
dependencies {
implementation("de.snowii:mojang-api:1.1.0")
}
Once you have added the library to your project, you can use the API in the MojangAPI class. For example, to get a GameProfile object for a given username:
GameProfile profile = MojangAPI.getGameProfile("Notch");
You can also get a GameProfile by UUID:
GameProfile profile = MojangAPI.getGameProfile(UUID.fromString("7bd9c2cb-079f-4f5b-925d-4bffdcf24aa8"));
If you are using a proxy, you can set it at the beginning of your code with:
MojangJSONParser.setProxy(<proxy>);
The Mojang API for Java is a powerful tool for Java developers who want to interact with Mojang's APIs. By using this library, you can quickly and easily fetch game profiles and UUIDs, and cache them for faster access.