Improve input spam prevention in cr
MelonBP
reports that the current input spam prevention as provided by our plots plugin is unwieldy and doesn't actually prevent people from spamming inputs.
He would like to propose a different way of handling input spam by introducing a per-input timeout. I think we can see this implemented one or multiple of the following forms:
- Timeout for all inputs in a plot
- Timeout per item id in a plot
- Timeout per block in a plot
3 would probably the most useful and is implemented on some other servers. It's been usually implemented by having the player look at the input and then performing a command to add a cooldown.
Implementation details for per-block timeout
We could keep a mapping of (x, y, z) -> timeout associated with a plot, as well as another mapping of (x, y, z) -> lastActivated.
Whenever a player right clicks a block in a plot:
- If the player is trusted or otherwise allowed to edit on the plot or bypass use flags, allow the right click.
- If the block id is not in the use flags, block the right click.
- If the coordinates of the click target are in the mapping,
- If this block was never activated or if its last activated time is outside the defined timeout, allow the right click.
- Otherwise, block the right click.
- Otherwise, resort to default behavior:
- Fall back to a per item id timeout, then to a plot-wide timeout, then a default config timeout, then to 0. Any timeouts can be left undefined or deleted to resort to fallback behavior.