A Java implementation of the mc-api.net API.
If you encounter any issues or bugs with our services or this library, please report them here.
A handler decides how a uuid or username is obtained. The default handler will just query the API and then cache the result. However you can create your own, custom handler.
There are two premade for Bukkit/Spigot and BungeeCord:
- Bukkit Handler: Checks if player is online or has played before, before querying API
- Bungee Handler: Checks if player is online before querying API
Just implement these somewhere within your project and then set it as the active handler using this example (example is for the BungeeHandler.
UUIDAPI.setHandler(new BungeeHandler());
We suggest you put it in the package: net.mcapi.uuid.handlers
Setting request server
MC-API has multiple mirrors, you can choose your mirror like so:
UUIDAPI.setRegion(ServerRegion)
A list of mirrors can be found here. The default mirror is set to US.
Username to UUID
UUID uuid = UUIDAPI.getUUID("AeroPvP");
Would return the UUID object for AeroPvP.
You can also get a string alternative (which does not contain hyphens)
String uuid = UUIDAPI.getUUIDString("AeroPvP");
UUID to Username
String playerName = UUIDAPI.getUsername("a8889e3068b84ce8963f4ea259c3ebe3");
Would return:
njb_said
If the given username or UUID is invalid, NULL
would be returned!
To compile just run mvn clean package
or download the latest build from build.mc-api.net
There is a maven repository at build.mc-api.net/plugin/repository/everything
Maven Configuration:
<repositories>
<repository>
<id>mcapi</id>
<url>http://build.mc-api.net/plugin/repository/everything/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>net.mcapi.uuid</groupId>
<artifactId>uuid-java</artifactId>
<version>1.1.3</version>
</dependency>
</dependencies>