A simple service to get player information.
repositories {
maven("https://jitpack.io")
}
dependencies {
implementation("rip.hippo:UUIDService:2.1.4")
}
If you decide to shade the dependency, be sure to install the PlayerListener
for better caching.
// Plugin main
@Override
public void onEnable() {
UUIDService.install(this);
}
// Getting player name from uuid
UUID uuid = ...;
String uuid = ...; // this may contain dashes however it is not required
Optional<String> nameOption = UUIDService.getName(uuid);
// Getting player uuid from name
String name = ...;
Optional<UUID> uuidOption = UUIDService.getUUID(name);
// Flush cache (note, the caches will be repopulated with data from the current online players)
UUIDService.flush();
There is also a utility method to create a UUID
from a UUID
string without dashes.
String dashless = "f4a3dde95c00409da71d7f23507de0f2";
UUID uuid = UUIDService.createUUID(dashless);