Add getOfflinePlayerIfCached(String)

This commit is contained in:
oxygencraft 2020-10-25 18:34:50 +11:00
parent 69fa242c6a
commit 30de939553

View file

@ -1968,6 +1968,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");