My newest project is called DoubleCheck. It’s a simple service plugin that provides a simple API for other plugins.
Motivation
There are many commands and actions that should be confirmed before the execution, for example a world deletion command, a money transfer, a ban command, or when you enter a PvP world.
Every plugin has it’s own command for this. The results are long command names and name conflicts.
It’s also really boring to develop something like this
DoubleCheck solves the problem with a unified action confirmation service. Plugins can easily use this service to send confirmation requests like this:
Are you sure that you want to send 2.000.000.000$ to Notch?
Please /confirm or /deny this action.
How it works
First of all, you have to build a class that implements the Request
interface:
Now, you can send requests:
ConfirmationService service = game.getServiceManager().provideUnchecked(ConfirmationService.class);
service.send(new TeleportRequest(fromPlayer, toPlayer, 30 /*seconds*/));
This is what the player gets:
boformer requested a teleport to you.
Please /confirm or /deny this action.
Configuration
The server admin will be able to change the command aliases (e.g confirm, ok, yes
or deny, cancel, no
) and all of the messages (and colors). Some examples:
Please confirm with /yes or cancel with /no
Are you sure? Confirm with /ok or deny with /cancel
Use this in your plugin!
Right now the plugin has to be installed on the Sponge server, so your plugins depend on it.
I will work on a version that can be bundled with your plugin.
To make sure that your plugin works even without DoubleCheck, use this fallback:
ConfirmationService service = game.getServiceManager().provide(ConfirmationService.class).orNull();
Request myRequest = new TeleportRequest(fromPlayer, toPlayer, 30 /*seconds*/)
if(service != null) service.send(myRequest);
else myRequest.confirm(); //just skips confirmation if DoubleCheck not installed
Source and Contributing
Right now some things are still missing (look at the TODO
markings). Pull Requests are welcome!
GitHub Repository: GitHub - boformer/DoubleCheck: Action Confirmation Library for Sponge Plugins