3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 04:20:04 +01:00
Paper/patches/api/0219-Add-getOfflinePlayerIfCached-String.patch
Nassim Jahnke d8e07590e3
Updated Upstream (Bukkit/CraftBukkit)
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:
5dbedae1 PR-864: Fix Registry#match() failing namespaced inputs
49256865 PR-863: Fix boolean PersistentDataType
9f15450b SPIGOT-7195, SPIGOT-7197: Add DataPack API
ebef5b6a Disable InterfaceIsType Checkstyle check
01d577f5 Slight tweak to boolean PersistentDataType javadoc
d2b99e56 PR-857: Add boolean PersistentDataType

CraftBukkit Changes:
2270366cd PR-1196: Test Registry instances more thoroughly
863dacb7a PR-1191: Do not start on pre-release Java 17
1f2dd8e12 SPIGOT-7362: Properly handle null in CraftBlock#blockFaceToNotch()
dbc70bed5 SPIGOT-7195, SPIGOT-7197: Add DataPack API
2023-06-06 11:09:19 +02:00

69 Zeilen
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 bae2ef297ba585c916ea06c4316e9511696000da..0bc59cd1b27303dff7f13f79087b13097606ae65 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -1250,6 +1250,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 31e8a002f9b0641f16bc4cf330e6022b13942321..247bd6d2101d280a00727cacdeb8f40a7d7c4dcb 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -1049,6 +1049,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.