mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-01 00:10:32 +01:00
40 lines
1.5 KiB
Diff
40 lines
1.5 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:34:50 +1100
|
|
Subject: [PATCH] Add getOfflinePlayerIfCached(String)
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
index a22b146e2bfdeb66aca8abb5fb23ee5cd6306f4e..99fa8f65801b1816b788fa42d49d6672bf331579 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
@@ -1933,6 +1933,28 @@ public final class CraftServer implements Server {
|
|
return result;
|
|
}
|
|
|
|
+ // Paper start
|
|
+ @Override
|
|
+ @Nullable
|
|
+ public OfflinePlayer getOfflinePlayerIfCached(String name) {
|
|
+ Preconditions.checkArgument(name != null, "Name cannot be null");
|
|
+ Preconditions.checkArgument(!name.isEmpty(), "Name cannot be empty");
|
|
+
|
|
+ OfflinePlayer result = getPlayerExact(name);
|
|
+ if (result == null) {
|
|
+ GameProfile profile = console.getProfileCache().getProfileIfCached(name);
|
|
+
|
|
+ if (profile != null) {
|
|
+ result = getOfflinePlayer(profile);
|
|
+ }
|
|
+ } else {
|
|
+ offlinePlayers.remove(result.getUniqueId());
|
|
+ }
|
|
+
|
|
+ return result;
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
@Override
|
|
public OfflinePlayer getOfflinePlayer(UUID id) {
|
|
Preconditions.checkArgument(id != null, "UUID id cannot be null");
|