mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-01 05:47:45 +01:00
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
This commit is contained in:
parent
d0d0b1a21e
commit
3f0a574e10
@ -1891,6 +1891,25 @@ public final class CraftServer implements Server {
|
|||||||
return recipients.size();
|
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 (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode()) {
|
||||||
|
profile = console.getProfileCache().get(name).orElse(null);
|
||||||
|
} 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
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public OfflinePlayer getOfflinePlayer(String name) {
|
public OfflinePlayer getOfflinePlayer(String name) {
|
||||||
|
Loading…
Reference in New Issue
Block a user