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
Adding Command Delays #451
Comments
Hey @Aseeef, thanks for the suggestion, and sorry for the delayed response! After some discussion on Discord, it was decided that delayed commands are probably outside the scope of the CommandAPI, so unfortunately this will probably not be added directly to the CommandAPI. The CommandAPI is focused on providing an interface for command features that are hard without Brigadier or NMS code. Delayed commands are possible using typical Spigot API, so they are probably outside of that scope. There are also many different ways developers may expect delayed commands to work, so it would be difficult for the CommandAPI to implement one solution that works for everyone. However, to help people who want to create delayed commands with the CommandAPI, PR #460 is going to add an example project to the CommandAPI that shows off some solutions. Hopefully, that example project will help guide developers in creating their own system, or they can just copy the code :P.
The PR doesn't actually have any examples yet, though I do have an idea of how I would implement a delayed command. If you think that system you used before can be adapted to the CommandAPI, you're welcome to add it to the PR! |
Description
Sometimes commands may perform (relatively) CPU-intensive tasks. In this case, you probably don't want players to execute the command too rapidly. A common use case for example could be for commands that perform database queries. The fix to this problem would be to add an execution delay between commands. This delay will be per player (although I suppose there might be use cases for a global delay too).
Spigot does have an "anti-command spam" limiter, and sure you can make this limiter more strict but spigot/paper's build in anti-command spam features apply to ALL commands. I think it would be useful to have the ability in CommandAPI to edit the delays per-command.
Previously, a command API I built for my plugins used this but after I switched to CommandAPI, this is the one feature I do miss from my stuff ;(
Expected code
new CommandAPICommand("command")
...
.withDelay(500, TimeUnit.MILLISECONDS)
...
Extra details
No response
The text was updated successfully, but these errors were encountered: