A simple Java library for translating a player's UUID to their current name, and a name to the player's UUID by using the official Mojang API. The API is documented here. No other functionality from the Mojang API is implemented in this project.
The specific implementations are as follows:
- Username to UUID
- Usernames to UUIDs
- UUID to Username (not documented)
You can obtain a copy of BasicMojangAPI via the following methods:
- Download a pre-built copy from the Releases page. The latest version is release 2.0.1.
- Build from source (see below).
- Include it as a dependency in your project (see the Development API section).
BasicMojangAPI uses Apache Maven to build and handle dependencies.
- Java Development Kit (JDK) 8 or higher
- Git
- Apache Maven
Run the following commands to build the library .jar
file:
git clone https://github.com/bspfsystems/BasicMojangAPI.git
cd BasicMojangAPI/
mvn clean install
The .jar
file will be located in the target/
folder.
To add BasicMojangAPI as a dependency to your project, use one of the following common methods (you may use others that exist, these are the common ones):
Maven:
Include the following in your pom.xml
file:
<repositories>
<repository>
<id>sonatype-repo</id>
<url>https://oss.sonatype.org/content/repositories/releases/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.bspfsystems</groupId>
<artifactId>basic-mojang-api</artifactId>
<version>2.0.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
Gradle:
Include the following in your build.gradle
file:
repositories {
maven {
url "https://oss.sonatype.org/content/repositories/releases/"
}
}
dependencies {
implementation "org.bspfsystems:basic-mojang-api:2.0.1"
}
These are some basic usages of BasicMojangAPI; for a full scope of what the library offers, please see the Javadocs section below.
// All methods have the chance to throw IOExceptions
try {
// Get the Account of a player from the current name, which contains
// the current name and UUID of the player
Account dinnerboneAccount = BasicMojangAPI.usernameToAccount("Dinnerbone");
UUID dinnerboneId = dinnerboneAccount.getUniqueId();
String dinnerboneName = dinnerboneAccount.getName();
// Get the current username from a player's UUID.
Account jeb_Account = BasicMojangAPI.uniqueIdToAccount(UUID.fromString("853c80ef-3c37-49fd-aa49-938b674adae6"));
UUID jeb_Id = jeb_Account.getUniqueId();
String jeb_Name = jeb_Account.getName();
} catch (IOException e) {
e.printStackTrace();
}
The API Javadocs can be found here, kindly hosted by javadoc.io.
Please check out CONTRIBUTING.md for more information.
BasicMojangAPI uses the following licenses:
Contributions to the project will remain licensed under the respective license, as defined by the particular license. Copyright/ownership of the contributions shall be governed by the license. The use of an open source license in the hopes that contributions to the project will have better clarity on legal rights of those contributions.
Please Note: This is not legal advice. If you are unsure on what your rights are, please consult a lawyer.