Denizen API Command Template

From Citizens Wiki

Denizen is extensible! In addition to Triggers and Requirements(soon!), an API is being provided to help you make custom Script Commands in your project! Have a neat idea for a command? Have a better way to STRIKE a player? (MEGASTRIKE command, anybody?)

Keep reading!


The ScriptEntry object

When Denizen reads scripts, each line is turned into a SciptScript object that contains the command, the arguments, and various other data and objects, as described below. Your command is an extension of this AbstractCommand class, and each time your command is called in for execution, it's this class that is executed and handled a ScriptEntry. How your Command uses the ScriptEntry information is of course, up to you.


YourCommand extends AbstractCommand

The first thing you need is a custom command class that extends the Denizen AbstractTrigger. This contains the method called when it's time for your command to be executed. This is called every-single-time a script contains your command.


Example Command

I think sometimes the easiest way to work is to see an example. View a copy of the STRIKE command on Pastie.org for a very simple command. For more examples, you can always [


Command Template

View a command template copy on Pastie.org for a copy/paste of the skeleton of a custom denizen commmand.


ScriptEntry hold runtime data

The Denizen ScriptEngine and Executer construct and fill a ScriptEntry with information that can be used in your command.

.getCommand()
Some more text
Useful if your command module contains instructions for more than one command. You can register multiple commands to your module, as discussed later in this document. See the ENGAGE command for a useful example of utilizing this information.