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

Adding Command Delays #451

Open
Aseeef opened this issue May 21, 2023 · 1 comment · May be fixed by #460
Open

Adding Command Delays #451

Aseeef opened this issue May 21, 2023 · 1 comment · May be fixed by #460
Labels
enhancement New feature or request

Comments

@Aseeef
Copy link

Aseeef commented May 21, 2023

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

@Aseeef Aseeef added the enhancement New feature or request label May 21, 2023
@willkroboth willkroboth linked a pull request Jun 8, 2023 that will close this issue
2 tasks
@willkroboth
Copy link
Collaborator

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.

Previously, a command API I built for my plugins used this

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!

willkroboth added a commit to willkroboth/CommandAPI that referenced this issue Jun 8, 2023
willkroboth added a commit to willkroboth/CommandAPI that referenced this issue Aug 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants