Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.
/ BasicMojangAPI Public archive

A simple Java library for translating between a player's username and their UUID.

License

Notifications You must be signed in to change notification settings

bspfsystems/BasicMojangAPI

Repository files navigation

BasicMojangAPI

THIS REPOSITORY IS NO LONGER MAINTAINED. NO FURTHER UPDATES WILL BE MADE.

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:

Obtaining BasicMojangAPI

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

Build from Source

BasicMojangAPI uses Apache Maven to build and handle dependencies.

Requirements

  • Java Development Kit (JDK) 8 or higher
  • Git
  • Apache Maven

Compile / Build

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.

Developer API

Add BasicMojangAPI as a Dependency

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"
}

API Examples

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();
}

Javadocs

The API Javadocs can be found here, kindly hosted by javadoc.io.

Contributing, Support, and Issues

Please check out CONTRIBUTING.md for more information.

Licensing

BasicMojangAPI uses the following licenses:

Contributions & Licensing

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.

About

A simple Java library for translating between a player's username and their UUID.

Topics

Resources

License

Stars

Watchers

Forks

Languages