Paper/patches/api/0229-Add-getOfflinePlayerIfCached-String.patch
Nassim Jahnke fb2c24b36d
Updated Upstream (Bukkit/CraftBukkit) (#8015)
Upstream has released updates that appear 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:
05ae036c PR-746: Add option to use cached map color palette
57849c1b PR-759: Add preview chat option in ServerListPingEvent
0169e65d PR-758: Add missing server properties methods from 1.19

CraftBukkit Changes:
622dbe6c2 SPIGOT-7068: SKULK and SKULK_VEIN BlockSpreadEvents Still do not reference the correct source (SKULK_CATALYST)
6c61b73f3 PR-1052: Add option to use cached map color palette
c882f38ea SPIGOT-7066: Fix custom END worlds not generating DragonBattle
6866aab59 SPIGOT-2420: Can't set exp drops for EnderDragon death
9dcd46530 PR-1067: Add preview chat option in ServerListPingEvent
36c2681af PR-1066: Add missing server properties methods from 1.19
031eaadd0 Increase outdated build delay
8fda4b12f SPIGOT-7060: SCULK and SCULK_VEIN BlockSpreadEvents do not reference the correct source
2022-06-20 19:12:05 +02:00

69 lines
2.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: oxygencraft <21054297+oxygencraft@users.noreply.github.com>
Date: Sun, 25 Oct 2020 18:35:58 +1100
Subject: [PATCH] Add getOfflinePlayerIfCached(String)
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index b34866d6314ec783661e7a806b3d8c2a3b338dd7..20ff922fe9248b822d751a7edb7468cc023de71b 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -1227,6 +1227,27 @@ public final class Bukkit {
return server.getOfflinePlayer(name);
}
+ // Paper start
+ /**
+ * Gets the player by the given name, regardless if they are offline or
+ * online.
+ * <p>
+ * This will not make a web request to get the UUID for the given name,
+ * thus this method will not block. However this method will return
+ * {@code null} if the player is not cached.
+ * </p>
+ *
+ * @param name the name of the player to retrieve
+ * @return an offline player if cached, {@code null} otherwise
+ * @see #getOfflinePlayer(String)
+ * @see #getOfflinePlayer(java.util.UUID)
+ */
+ @Nullable
+ public static OfflinePlayer getOfflinePlayerIfCached(@NotNull String name) {
+ return server.getOfflinePlayerIfCached(name);
+ }
+ // Paper end
+
/**
* Gets the player by the given UUID, regardless if they are offline or
* online.
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 8768f544ca3b197a6456bf948c05a4cfb8f776a1..a3ae5651718937bdefff1753b93c7c67aff7ef1d 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -1022,6 +1022,25 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@NotNull
public OfflinePlayer getOfflinePlayer(@NotNull String name);
+ // Paper start
+ /**
+ * Gets the player by the given name, regardless if they are offline or
+ * online.
+ * <p>
+ * This will not make a web request to get the UUID for the given name,
+ * thus this method will not block. However this method will return
+ * {@code null} if the player is not cached.
+ * </p>
+ *
+ * @param name the name of the player to retrieve
+ * @return an offline player if cached, {@code null} otherwise
+ * @see #getOfflinePlayer(String)
+ * @see #getOfflinePlayer(java.util.UUID)
+ */
+ @Nullable
+ public OfflinePlayer getOfflinePlayerIfCached(@NotNull String name);
+ // Paper end
+
/**
* Gets the player by the given UUID, regardless if they are offline or
* online.