Replace command-costs and command-cooldowns with command filters system
mdcfe opened this issue ยท 2 comments
Currently, command-costs
and command-cooldowns
are separate and behave slightly differently - command-costs
only supports EssentialsX's own commands and doesn't support regexes, while command-cooldowns
supports external plugins commands but doesn't ensure that the command succeeds before setting the cooldown.
The new filters system could be implemented in a separate config, which is a list of filters that contain the following options:
name
(optional): a name for the filter, allowing perms to bypass specific filters (as well as allowing us to track cooldowns in player data; if none is provided then we can auto generate a name)command
(required unlesspattern
is provided): the name of an EssentialsX command; these filters will ensure that the command succeeds before charging the player or starting the cooldownpattern
(required unlesscommand
is provided): a regex to match any plugin's command against; these filters will not check whether the command succeedscooldown
(optional): the length of time that the player will have to wait until they can use a command matching this filter again, in secondscost
(optional): the amount that will be deducted from the player's economy balance when they use the command
An example looks something like this:
filters:
- pattern: "ban([^ip])(.*)?" # regex - doesn't ensure success
cooldown: 60
- command: "warp" # EssentialsX built-in command - ensures success before deducting cost and starting cooldown
cost: 100
cooldown: 10
- name: "projectiles" # option
pattern: "(fireball|kittycannon|beezooka)"
cost: 10000
The use of a command
or pattern
parameter instead of a map key also avoids a bug with the current command-cooldowns
where any regex pattern that includes .
fails to parse due to YAML syntax errors.
It would be ideal to also migrate over old cooldowns to the new system (similar to how kits were done).
Would definitely love something like that! Lack of permission support per command is what I currently miss from these command cooldowns.