2021-06-11 14:02:28 +02:00
|
|
|
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
|
2024-07-06 21:19:14 +02:00
|
|
|
index 1a671331ec4ab21430d7d52e9a4f45510ef39944..e0f652117e585882693736de8165ae9c689e1d68 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/Bukkit.java
|
|
|
|
+++ b/src/main/java/org/bukkit/Bukkit.java
|
2024-07-06 21:19:14 +02:00
|
|
|
@@ -1374,6 +1374,27 @@ public final class Bukkit {
|
2021-06-11 14:02:28 +02:00
|
|
|
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
|
2024-07-06 21:19:14 +02:00
|
|
|
index 7dbd9b32e96c015e3ed757ea0fa7e2bfcf4af85e..90111a9ae0b7bdd6e46e869398dc6b9898b5f87e 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/Server.java
|
|
|
|
+++ b/src/main/java/org/bukkit/Server.java
|
2024-07-06 21:19:14 +02:00
|
|
|
@@ -1161,6 +1161,25 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
2021-06-11 14:02:28 +02:00
|
|
|
@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.
|