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

Username resolving rework #1311

Merged
merged 5 commits into from
May 12, 2024
Merged

Username resolving rework #1311

merged 5 commits into from
May 12, 2024

Conversation

Pablete1234
Copy link
Member

Rewrites how username resolving works in pgm to make it more reliable. At the moment Unknown prevails and is shown way too often, this rewrite fixes a big amount of hidden bugs and quirks with the original system like, to name a few:

  • SQL was only used to resolve usernames after you called getNameLegacy
  • API based resolution was queued up as soon as you asked for a username
    • We shouldn't need to hit the API is local SQL resolves correctly!!
  • API based resolution queue only processed after /newmaps, or on match end due to stats side-effect
  • SQL was not batched, meaning 100s of queries to retrieve all author names
  • SQL would query, then save itself back into the database with updated expiry

The new resolution system isn't flawless, but it's much better than the predecessor.

There's a series of UsernameResolvers, they can work in batch mode (in which case they no-op until the end of the batch) or in normal mode. They return a CompletableFuture with the result of the resolution. You can setup multiple of them to work in a chain, where the first resolver is tried, if it gives a good answer that's returned via the future, otherwise the next resolver is tried, until one of them gives a good answer, or we run out of resolvers. They can also chain in batching mode where the first will resolve everything (sending downstream the not-well-resolved ones), then the 2nd tries to resolve the remaining batch, and so on.

The main caveat that still seems not to work too well is bukkit's username cache, which seems to either not keep users or say their last played time was 0. Using vanilla's user cache via nmshacks seems to work around the issue and allow for "instant resolving" to work just fine.

@Pablete1234 Pablete1234 added the refactor Code needs to be redesigned label Apr 27, 2024
@Pablete1234 Pablete1234 marked this pull request as ready for review May 2, 2024 20:20
Signed-off-by: Pablo Herrera <[email protected]>
@Pablete1234 Pablete1234 added the ready PR is ready to merge label May 4, 2024
@Electroid Electroid merged commit 6d924c8 into dev May 12, 2024
2 checks passed
@Electroid Electroid deleted the username-resolving-rework branch May 12, 2024 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready PR is ready to merge refactor Code needs to be redesigned
Development

Successfully merging this pull request may close these issues.

3 participants