Skip to content

Commit

Permalink
docs for tab-completion of jsp command using function
Browse files Browse the repository at this point in the history
  • Loading branch information
walterhiggins committed Jun 14, 2014
1 parent 8c3c7d6 commit bded5e8
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion docs/API-Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ The `command()` function is used to expose javascript functions for use by non-o
* params : An Array of type String - the list of parameters passed to the command.
* sender : The [CommandSender][bukcs] object that invoked the command (this is usually a Player object but can be a Block ([BlockCommandSender][bukbcs]).

* options (Array - optional) : An array of command options/parameters which the player can supply (It's useful to supply an array so that Tab-Completion works for the `/jsp ` commands.
* options (Array|Function - optional) : An array of command options/parameters which the player can supply (It's useful to supply an array so that Tab-Completion works for the `/jsp ` commands. If a function is supplied instead of an array then the function will be invoked at TAB-completion time and should return an array of strings.
* intercepts (boolean - optional) : Indicates whether this command can intercept Tab-Completion of the `/jsp ` command - advanced usage - see alias/alias.js for example.

#### Example
Expand All @@ -627,6 +627,17 @@ The `command()` function is used to expose javascript functions for use by non-o
/jsp boo Hi!
> Hi!

To use a callback for options (TAB-Completion) ...


function boo( params, sender ) {
var receiver = server.getPlayer( params[0] );
if ( receiver ){
receiver.sendMessage( sender.name + ' says boo!');
}
}
command( boo, bukkit.playerNames );

See chat/colors.js or alias/alias.js or homes/homes.js for more examples of how to use the `command()` function.

### setTimeout() function
Expand Down

0 comments on commit bded5e8

Please sign in to comment.