diff --git a/common/src/main/java/net/william278/husksync/api/HuskSyncAPI.java b/common/src/main/java/net/william278/husksync/api/HuskSyncAPI.java index 451d9b90..5fc2272e 100644 --- a/common/src/main/java/net/william278/husksync/api/HuskSyncAPI.java +++ b/common/src/main/java/net/william278/husksync/api/HuskSyncAPI.java @@ -99,6 +99,18 @@ public CompletableFuture> getUser(@NotNull UUID 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 this server. + * @since 3.7.2 + */ + @NotNull + public Optional getOnlineUser(@NotNull UUID uuid) { + return plugin.getOnlineUser(uuid); + } + /** * Get a {@link User} by their username * diff --git a/docs/API.md b/docs/API.md index 30bcd181..40c8f79c 100644 --- a/docs/API.md +++ b/docs/API.md @@ -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. * `common` - Common API for all platforms. -
Targeting older versions diff --git a/docs/Data-Snapshot-API.md b/docs/Data-Snapshot-API.md index ec777c95..118ca886 100644 --- a/docs/Data-Snapshot-API.md +++ b/docs/Data-Snapshot-API.md @@ -43,6 +43,7 @@ huskSyncAPI.getUser(uuid).thenAccept(optionalUser -> {
* 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.
Code Example — Getting an online user