Home›Java›Mods›OfflinePlayerLib
OfflinePlayerLib
ModsJava

OfflinePlayerLib

Java mod listed for Minecraft 1.21–26.x. Downloads from the MC Java Mods app on Android.

by PixelCatt · on Modrinth

⬇ Download on Modrinth
OfflinePlayerLib-Icon

OfflinePlayerLib

OfflinePlayerLib — Minecraft Java mod, screenshot 1 OfflinePlayerLib — Minecraft Java mod, screenshot 2

How Lookups Work

When doing a Lookup, Saved Players in the DB are checked first, then the User Cache and GeyserMC/Floodgate + LibreLogin are used.
A lookup returns with null when the Identity cannot be determined.

GetAllOfflinePlayers returns a List<CachedOfflinePlayer>.
GetOfflinePlayerByName and GetOfflinePlayerByUUID return a CompletableFuture<CachedOfflinePlayer>.

CachedOfflinePlayer holds the Name and UUID and provides getOfflinePlayer() when a Bukkit Player is needed.

Using the OfflinePlayer API

Add it as a provided dependency when compiling your Plugin:

<dependency>
  <groupId>com.pixelcatt.offlineplayerlib</groupId>
  <artifactId>OfflinePlayerLib</artifactId>
  <version>VERSION-HERE</version>
  <scope>provided</scope>
</dependency>

Declare OfflinePlayerLib as a dependency in your plugin's plugin.yml so it loads first:

depend: [OfflinePlayerLib]

Import OfflinePlayerLib and the ChachedPlayer Type:

import com.pixelcatt.offlineplayerlib.OfflinePlayerLib;
import com.pixelcatt.offlineplayerlib.CachedOfflinePlayer;

Then get the Plugin Instance:

OfflinePlayerLib offlinePlayerLib = (OfflinePlayerLib) getServer().getPluginManager().getPlugin("OfflinePlayerLib");

And use these Methods to Lookup Offline Players:

// Look up by Username
offlinePlayerLib.GetOfflinePlayerByName(username).thenAccept(playerByName -> {
    if (playerByName != null) {
        System.out.println(playerByName.getUniqueId());
    }
});

// Look up by UUID
offlinePlayerLib.GetOfflinePlayerByUUID(UUID).thenAccept(playerByUUID -> {
    if (playerByUUID != null) {
        System.out.println(playerByName.getName());
    }
});

// Get a list of All Saved Offline Players
offlinePlayerLib.GetAllOfflinePlayers().thenAccept(players -> {
    players.forEach(player ->
        System.out.println(player.getName() + " - " + player.getUniqueId())
    );
});
Quick facts

Install steps are the general flow for this file type — How to install Minecraft Java mods & modpacks walks through it step by step.

File checked by MCModsHub

These come from our own check of the pack file, not from the source page.

Explore more