You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
The regular getOfflinePlayer is a minefield. You never know if you're not locking up the MainThread with an HTTP Request.
This means folks have started writing their own UUID Lookup classes, which do not share their cache with the server, which is suboptimal and also such hacks shouldn't be required with a good API.
In most cases, it's good to at least check if the Player is a cache hit and thus operation can complete as usual or if a HTTP Request would be triggered (in which case plugins can decide whether to go async or quit the operation).
Describe the solution you'd like
I think ultimatively it would be nice to expose the UserCache using an API, but the more immediate solution would be (imo) to enhance CraftServer#getOfflinePlayer(String) with a getOfflinePlayerIfCached(String) which calls into UserCache#getProfileIfCached
Describe alternatives you've considered
Ensuring and clearly stating that getOfflinePlayer is threadsafe.
If this is different to spigot, this could, however, lead to plugin authors thinking that spigot's impl is also thread safe.
And ultimatively it still does an HTTP request, which may not be wanted by the author (e.g. friend requests for not-cached users could just be rejected with "this user wasn't seen recently").
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
The regular getOfflinePlayer is a minefield. You never know if you're not locking up the MainThread with an HTTP Request.
This means folks have started writing their own UUID Lookup classes, which do not share their cache with the server, which is suboptimal and also such hacks shouldn't be required with a good API.
In most cases, it's good to at least check if the Player is a cache hit and thus operation can complete as usual or if a HTTP Request would be triggered (in which case plugins can decide whether to go async or quit the operation).
Describe the solution you'd like
I think ultimatively it would be nice to expose the UserCache using an API, but the more immediate solution would be (imo) to enhance
CraftServer#getOfflinePlayer(String)
with agetOfflinePlayerIfCached(String)
which calls intoUserCache#getProfileIfCached
Describe alternatives you've considered
Ensuring and clearly stating that getOfflinePlayer is threadsafe.
If this is different to spigot, this could, however, lead to plugin authors thinking that spigot's impl is also thread safe.
And ultimatively it still does an HTTP request, which may not be wanted by the author (e.g. friend requests for not-cached users could just be rejected with "this user wasn't seen recently").
The text was updated successfully, but these errors were encountered: