Paper/Spigot-Server-Patches/0204-getPlayerUniqueId-API.patch
Aikar ab347c4c96
Updated Upstream (Bukkit/CraftBukkit/Spigot)
Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
42d5a714 SPIGOT-5899: Hoglins API similar to Piglins
2c1ee10e SPIGOT-5887: ClickType doesn't include off hand swaps
5ff7c7ce SPIGOT-5886: Missing BlockData

CraftBukkit Changes:
7560f5f5 SPIGOT-5905: Fix hex colours not being allowed in MOTD
d47c47ee SPIGOT-5889: Villager using composter should call EntityChangeBlockEvent
2fe6b4a3 SPIGOT-5899: Hoglins API similar to Piglins
e09dbeca SPIGOT-5887: ClickType doesn't include off hand swaps
23aac2a5 SPIGOT-5903: EntityDismountEvent cannot be triggered asynchronously
92cbf656 SPIGOT-5884: Tab completions lost on reloadData / minecraft:reload
fb4e54ad SPIGOT-5902: PlayerRespawnEvent places player at spawn before event is called
aa8f3d5a SPIGOT-5901: Structures are generated in all worlds based on the setting for the main world
a0c35937 SPIGOT-5895: PlayerChangedWorldEvent#getFrom is incorrect
89c0a5c3 SPIGOT-5886: Missing BlockData

Spigot Changes:
0287a20d SPIGOT-5903: EntityDismountEvent cannot be triggered asynchronously
2020-06-30 01:20:29 -04:00

42 lines
1.8 KiB
Diff

From 0000000000000000000000000000000000000000 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 3954eb18bb28ad9033c957e05a13068b8751dbc9..22b5a20b1183d2421e4f43245b1ace30adffb7e8 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1481,6 +1481,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 (net.minecraft.server.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) {