Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add getOfflinePlayerIfCached(String) #4264

Closed
MeFisto94 opened this issue Sep 1, 2020 · 0 comments · Fixed by #4687
Closed

Add getOfflinePlayerIfCached(String) #4264

MeFisto94 opened this issue Sep 1, 2020 · 0 comments · Fixed by #4687
Labels
type: feature Request for a new Feature.

Comments

@MeFisto94
Copy link
Contributor

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").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature Request for a new Feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants