8000 [Feat] AsyncOfflinePlayerArgument by Bram1903 · Pull Request #633 · CommandAPI/CommandAPI · GitHub
[go: up one dir, main page]

Skip to content

[Feat] AsyncOfflinePlayerArgument #633

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

Merged

Conversation

Bram1903
Copy link
Contributor
@Bram1903 Bram1903 commented Jan 12, 2025

Description

This pull request introduces the AsyncOfflinePlayerArgument, which extends the SafeOverrideableArgument class. The new class wraps the existing OfflinePlayerArgument within a CompletableFuture<OfflinePlayer>, enabling asynchronous handling of the offline player argument in commands. By using this approach, the logic involving API calls to fetch the offline player will be executed off the main thread, reducing the risk of blocking the server's main thread and improving performance.

PR Checklist

  • Does the pull request have clear and descriptive commit messages that explain the changes made?
  • Does the CommandAPI compile successfully? (This will be verified automatically when the pull request is made.)
  • Has this been tested in a Minecraft server environment, including compatibility with the latest Minecraft version and Spigot or Paper?
  • Are unit tests required for this feature, and if so, have they been added to the pull request?
  • Is documentation included in this pull request, and does it adequately explain the new functionality?

Documentation

See CommandAPI/docs#1

This PR is in continuation of #632, which I accidentally closed :-)

Copy link
Collaborator
@willkroboth willkroboth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't personally tested functionality, but code looks good and makes sense to me.

I think it's fine to not include any automated tests in this PR given that OfflinePlayerArgument doesn't have any tests yet. I'm not sure how MockBukkit handles offline players, so that's something that could just be figured out later.

@Bram1903
Copy link
Contributor Author

The reason I didn't include a separate unit test for this is that the OfflinePlayerArgument is already being tested in the ProfileArgumentTypeTests. This argument essentially wraps OfflinePlayerArgument into a CompletableFuture<OfflinePlayerArgument>, leveraging its existing functionality. Since the core behavior is already validated, additional tests here would be redundant.

@DerEchtePilz
Copy link
Member

Yeah, that doesn't test the actual OfflinePlayerArgument, that tests the custom implementation we have for the test toolkit to make it NMS independent.

@Bram1903
Copy link
Contributor Author

Yeah, that doesn't test the actual OfflinePlayerArgument, that tests the custom implementation we have for the test toolkit to make it NMS independent.

Whoops, I see! Thanks for the heads up :-)

@willkroboth willkroboth merged commit 587d087 into CommandAPI:dev/dev Jan 17, 2025
2 checks passed
willkroboth added a commit to CommandAPI/docs that referenced this pull request Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0