LibertyBans icon indicating copy to clipboard operation
LibertyBans copied to clipboard

[Feature Request] A way to execute custom commands on issuing/removing a punishment

Open eingruenesbeb opened this issue 1 year ago • 1 comments

I have confirmed that ...

  • [X] There is no duplicate feature request.

Description

I think it would be very beneficial to have a feature, that allows you to run custom commands, when you issue a punishment to a player and when it‘s vice versa revoked/expired.

Example:

  • When you need to remove/add certain permissions from a muted player.
  • If you want to make items of banned players available to others by summoning a chest with their loot.
  • Sending a custom message to a player, that has had their punishment removed.
  • Adding effects like lightning

A few extra wishes for the finer details:

  • You should be able to specify, if the commands should execute before or after the action.
  • You should be able to configure, whether the action should continue, if the commands fail.
  • There be a way to specify different commands, based on context?

eingruenesbeb avatar Oct 28 '23 13:10 eingruenesbeb

We have an API for this reason. Using the LibertyBans API, developers can build different external plugins that perform these actions. For example, effects like lightning or sound can be triggered after a player is punished. You can also intercept punishments and cancel them depending on circumstances. All of this is possible if you know how to write an extra plugin.


I will caution you that there is no way to know if a command fails. For example, if a plugin (any plugin) issues a console command like /ban A248, it is impossible to check if the ban actually succeeded. There might be some tricks you can accomplish such as invoking the command executor directly; however, these choices are intentionally left to third-party plugins, and I don't think it makes sense to add them to the core LibertyBans plugin.

I will also warn you that it is difficult to know when a punishment is expired. I believe @BlueTree242 made a mechanism to fire an expiration event. However, the LibertyBans API does not expose this functionality because it implies a lot of overhead involved in checking for expiration.

A248 avatar Oct 28 '23 15:10 A248