aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/api/0090-getPlayerUniqueId-API.patch
blob: 4ded35b02d4fe15629372da0753045009d9af72f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Thu, 22 Mar 2018 01:39:28 -0400
Subject: [PATCH] getPlayerUniqueId API

Gets the unique ID of the player currently known as the specified player name
In Offline Mode, will return an Offline UUID

This is a more performant way to obtain a UUID for a name than loading an OfflinePlayer

diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index da18fbc38976c601da7781b488449da7d724160f..28b86658aea14b33470508944d8626b23c65bba2 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -753,6 +753,20 @@ public final class Bukkit {
         return server.getPlayer(id);
     }
 
+    // Paper start
+    /**
+     * Gets the unique ID of the player currently known as the specified player name
+     * In Offline Mode, will return an Offline UUID
+     *
+     * @param playerName the player name to look up the unique ID for
+     * @return A UUID, or null if that player name is not registered with Minecraft and the server is in online mode
+     */
+    @Nullable
+    public static UUID getPlayerUniqueId(@NotNull String playerName) {
+        return server.getPlayerUniqueId(playerName);
+    }
+    // Paper end
+
     /**
      * Gets the plugin manager for interfacing with plugins.
      *
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 01c052d90bbdad3fc374eb9c8e0a5133b8b624e8..5c6c9f714097dfaead0093d752f1b373b70a75eb 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -633,6 +633,18 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
     @Nullable
     public Player getPlayer(@NotNull UUID id);
 
+    // Paper start
+    /**
+     * Gets the unique ID of the player currently known as the specified player name
+     * In Offline Mode, will return an Offline UUID
+     *
+     * @param playerName the player name to look up the unique ID for
+     * @return A UUID, or null if that player name is not registered with Minecraft and the server is in online mode
+     */
+    @Nullable
+    public UUID getPlayerUniqueId(@NotNull String playerName);
+    // Paper end
+
     /**
      * Gets the plugin manager for interfacing with plugins.
      *