org.bukkit.command
Class PluginCommand

java.lang.Object
  extended by org.bukkit.command.Command
      extended by org.bukkit.command.PluginCommand
All Implemented Interfaces:
PluginIdentifiableCommand

public final class PluginCommand
extends Command
implements PluginIdentifiableCommand

Represents a Command belonging to a plugin


Field Summary
 
Fields inherited from class org.bukkit.command.Command
description, usageMessage
 
Constructor Summary
protected PluginCommand(String name, Plugin owner)
           
 
Method Summary
 boolean execute(CommandSender sender, String commandLabel, String[] args)
          Executes the command, returning its success
 CommandExecutor getExecutor()
          Gets the CommandExecutor associated with this command
 Plugin getPlugin()
          Gets the owner of this PluginCommand
 TabCompleter getTabCompleter()
          Gets the TabCompleter associated with this command.
 void setExecutor(CommandExecutor executor)
          Sets the CommandExecutor to run when parsing this command
 void setTabCompleter(TabCompleter completer)
          Sets the TabCompleter to run when tab-completing this command.
 List<String> tabComplete(CommandSender sender, String alias, String[] args)
          Executed on tab completion for this command, returning a list of options the player can tab through.
 String toString()
           
 
Methods inherited from class org.bukkit.command.Command
broadcastCommandMessage, broadcastCommandMessage, getAliases, getDescription, getLabel, getName, getPermission, getPermissionMessage, getUsage, isRegistered, register, setAliases, setDescription, setLabel, setPermission, setPermissionMessage, setUsage, tabComplete, testPermission, testPermissionSilent, unregister
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PluginCommand

protected PluginCommand(String name,
                        Plugin owner)
Method Detail

execute

public boolean execute(CommandSender sender,
                       String commandLabel,
                       String[] args)
Executes the command, returning its success

Specified by:
execute in class Command
Parameters:
sender - Source object which is executing this command
commandLabel - The alias of the command used
args - All arguments passed to the command, split via ' '
Returns:
true if the command was successful, otherwise false

setExecutor

public void setExecutor(CommandExecutor executor)
Sets the CommandExecutor to run when parsing this command

Parameters:
executor - New executor to run

getExecutor

public CommandExecutor getExecutor()
Gets the CommandExecutor associated with this command

Returns:
CommandExecutor object linked to this command

setTabCompleter

public void setTabCompleter(TabCompleter completer)
Sets the TabCompleter to run when tab-completing this command.

If no TabCompleter is specified, and the command's executor implements TabCompleter, then the executor will be used for tab completion.

Parameters:
completer - New tab completer

getTabCompleter

public TabCompleter getTabCompleter()
Gets the TabCompleter associated with this command.

Returns:
TabCompleter object linked to this command

getPlugin

public Plugin getPlugin()
Gets the owner of this PluginCommand

Specified by:
getPlugin in interface PluginIdentifiableCommand
Returns:
Plugin that owns this command

tabComplete

public List<String> tabComplete(CommandSender sender,
                                String alias,
                                String[] args)
                         throws CommandException,
                                IllegalArgumentException
Executed on tab completion for this command, returning a list of options the player can tab through.

Delegates to the tab completer if present.
If it is not present or returns null, will delegate to the current command executor if it implements TabCompleter. If a non-null list has not been found, will default to standard player name completion in Command.tabComplete(CommandSender, String, String[]).

This method does not consider permissions.

Overrides:
tabComplete in class Command
Parameters:
sender - Source object which is executing this command
alias - the alias being used
args - All arguments passed to the command, split via ' '
Returns:
a list of tab-completions for the specified arguments. This will never be null. List may be immutable.
Throws:
CommandException - if the completer or executor throw an exception during the process of tab-completing.
IllegalArgumentException - if sender, alias, or args is null

toString

public String toString()
Overrides:
toString in class Command


Copyright © 2013. All Rights Reserved.