From bb5b1f8db4bfdccd4911290e7da941dd44c1feff Mon Sep 17 00:00:00 2001 From: "Vincent B." <79211348+Snabeldier@users.noreply.github.com> Date: Sun, 22 Dec 2024 21:38:25 +0100 Subject: [PATCH] docs(Core): add some docs to user related methods and position them higher (#252) --- src/main/java/minevalley/core/api/Core.java | 100 ++++++++++++------ .../core/api/users/OnTimeHandler.java | 11 ++ 2 files changed, 77 insertions(+), 34 deletions(-) diff --git a/src/main/java/minevalley/core/api/Core.java b/src/main/java/minevalley/core/api/Core.java index 17703031..dad3aede 100644 --- a/src/main/java/minevalley/core/api/Core.java +++ b/src/main/java/minevalley/core/api/Core.java @@ -63,6 +63,8 @@ import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.util.Vector; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; import java.text.SimpleDateFormat; import java.time.DayOfWeek; import java.util.*; @@ -145,6 +147,70 @@ public static void callEvent(Event event) { server.callEvent(event); } + /** + * Gets the user of with a specific unique id. + *
+ * Note: If no user is found, this method returns null. + * + * @param uniqueId unique id to get user from + * @return user object of the given unique id + */ + @Nullable + public static User getUser(@Nonnull UUID uniqueId) { + return server.getUser(uniqueId); + } + + /** + * Gets the user of this specific player. + *
+ * Note: If no user is found, a new one is created based on the player. + * + * @param player player to get user from + * @return user object of the given player + */ + @NonNull + public static OnlineUser getOnlineUser(@Nonnull Player player) { + return server.getOnlineUser(player); + } + + /** + * Gets the name of the player with the specific unique id. + *
+ * Note: If no player is found, this method returns null. + *

+ * Runtime Optimization + *

+ *

+ * + * @param uniqueId unique id of the player + * @return name of the player + */ + @Nullable + public static String getName(@Nonnull UUID uniqueId) { + return server.getName(uniqueId); + } + + /** + * Gets the unique id of the player with the specific name. + *
+ * Note: If no player is found, this method returns null. + *

+ * Runtime Optimization + *