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
Dieser Commit ist enthalten in:
Ursprung
b63ac711e0
Commit
b29f5c05c1
61
Spigot-API-Patches/0091-getPlayerUniqueId-API.patch
Normale Datei
61
Spigot-API-Patches/0091-getPlayerUniqueId-API.patch
Normale Datei
@ -0,0 +1,61 @@
|
||||
From 780999dfaf18ca6223e57e089241ff73a95e8ccd 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 690d9c07..682d2bbf 100644
|
||||
--- a/src/main/java/org/bukkit/Bukkit.java
|
||||
+++ b/src/main/java/org/bukkit/Bukkit.java
|
||||
@@ -424,6 +424,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(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 f2ee6516..2912bdae 100644
|
||||
--- a/src/main/java/org/bukkit/Server.java
|
||||
+++ b/src/main/java/org/bukkit/Server.java
|
||||
@@ -354,6 +354,18 @@ public interface Server extends PluginMessageRecipient {
|
||||
*/
|
||||
public Player getPlayer(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(String playerName);
|
||||
+ // Paper end
|
||||
+
|
||||
/**
|
||||
* Gets the plugin manager for interfacing with plugins.
|
||||
*
|
||||
--
|
||||
2.16.2
|
||||
|
44
Spigot-Server-Patches/0281-getPlayerUniqueId-API.patch
Normale Datei
44
Spigot-Server-Patches/0281-getPlayerUniqueId-API.patch
Normale Datei
@ -0,0 +1,44 @@
|
||||
From 4f8924548dc2ad84bd261462e5419ab0c08705b4 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Thu, 22 Mar 2018 01:40:24 -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/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 6095948e8..80702f6f6 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -1346,6 +1346,26 @@ public final class CraftServer implements Server {
|
||||
return recipients.size();
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ @Nullable
|
||||
+ public UUID getPlayerUniqueId(String name) {
|
||||
+ Player player = Bukkit.getPlayerExact(name);
|
||||
+ if (player != null) {
|
||||
+ return player.getUniqueId();
|
||||
+ }
|
||||
+ GameProfile profile;
|
||||
+ // Only fetch an online UUID in online mode
|
||||
+ if (MinecraftServer.getServer().getOnlineMode()
|
||||
+ || (org.spigotmc.SpigotConfig.bungee && com.destroystokyo.paper.PaperConfig.bungeeOnlineMode)) {
|
||||
+ profile = console.getUserCache().getProfile( name );
|
||||
+ } else {
|
||||
+ // Make an OfflinePlayer using an offline mode UUID since the name has no profile
|
||||
+ profile = new GameProfile(UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8)), name);
|
||||
+ }
|
||||
+ return profile != null ? profile.getId() : null;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
@Override
|
||||
@Deprecated
|
||||
public OfflinePlayer getOfflinePlayer(String name) {
|
||||
--
|
||||
2.16.2
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren