9
0
mirror of https://github.com/WiIIiam278/HuskSync.git synced 2025-12-19 14:59:21 +00:00

feat: add method for getting OnlineUser in common module

This commit is contained in:
William
2024-12-07 20:56:22 +00:00
parent cedd12a048
commit 1820a810f4
3 changed files with 13 additions and 1 deletions

View File

@@ -99,6 +99,18 @@ public class HuskSyncAPI {
return plugin.supplyAsync(() -> plugin.getDatabase().getUser(uuid)); return plugin.supplyAsync(() -> plugin.getDatabase().getUser(uuid));
} }
/**
* Get an {@link OnlineUser} by their UUID
*
* @param uuid the UUID of the user to get
* @return The {@link OnlineUser} wrapped in an optional, if they are online on <i>this</i> server.
* @since 3.7.2
*/
@NotNull
public Optional<OnlineUser> getOnlineUser(@NotNull UUID uuid) {
return plugin.getOnlineUser(uuid);
}
/** /**
* Get a {@link User} by their username * Get a {@link User} by their username
* *

View File

@@ -20,7 +20,6 @@ The HuskSync API is available for the following platforms:
* `fabric` - Fabric API for Minecraft. Provides Fabric API event listeners and adapters to `net.minecraft` objects. * `fabric` - Fabric API for Minecraft. Provides Fabric API event listeners and adapters to `net.minecraft` objects.
* `common` - Common API for all platforms. * `common` - Common API for all platforms.
<details> <details>
<summary>Targeting older versions</summary> <summary>Targeting older versions</summary>

View File

@@ -43,6 +43,7 @@ huskSyncAPI.getUser(uuid).thenAccept(optionalUser -> {
</details> </details>
* If you have an online `org.bukkit.Player` object, you can use `BukkitPlayer#adapt(player)` to get an `OnlineUser` (extends `User`), representing a logged-in user. * If you have an online `org.bukkit.Player` object, you can use `BukkitPlayer#adapt(player)` to get an `OnlineUser` (extends `User`), representing a logged-in user.
* You can also use `#getOnlineUser(UUID)` to get an OnlineUser by their UUID - note this only works for players online on the server the logic is called from, however.
<details> <details>
<summary>Code Example &mdash; Getting an online user</summary> <summary>Code Example &mdash; Getting an online user</summary>