mondocommand
Class SubCommand

java.lang.Object
  extended by mondocommand.SubCommand

public final class SubCommand
extends Object

Represents a sub-command which can be generated by method chaining.

Author:
James Crasta

Constructor Summary
SubCommand(String name, String permission)
          Create a new SubCommand.
 
Method Summary
 SubCommand allowConsole()
          Allow this command to be used on the console.
 boolean checkPermission(org.bukkit.command.CommandSender sender)
          Check if a Player/CommandSender has the requisite permission for this command.
 String getDescription()
          Get the command's description.
 SubHandler getHandler()
          Get the currently set SubHandler.
 int getMinArgs()
          Check what the minimum number of args is
 String getName()
          Get the command's name.
 String getPermission()
          Get the permission node this command is required to use.
 String getUsage()
          Get the usage string.
 boolean isConsoleAllowed()
          If true, console access is allowed.
 SubCommand setDescription(String description)
          Set the command's description.
 SubCommand setHandler(SubHandler handler)
          Set the SubHandler.
 SubCommand setMinArgs(int minArgs)
          Set the minimum number of arguments this command accepts.
 SubCommand setUsage(String usage)
          Set this command's usage string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SubCommand

public SubCommand(String name,
                  String permission)
Create a new SubCommand.

Parameters:
name - The text of this subcommand.
permission - The permission to check for this command. If null, don't use permissions.
Method Detail

allowConsole

public SubCommand allowConsole()
Allow this command to be used on the console. If this is not set, then the command only works for players.


isConsoleAllowed

public boolean isConsoleAllowed()
If true, console access is allowed.


getMinArgs

public int getMinArgs()
Check what the minimum number of args is


setMinArgs

public SubCommand setMinArgs(int minArgs)
Set the minimum number of arguments this command accepts. If minArgs is >0, then the handler will not be executed unless this many arguments to the command are present.

Parameters:
minArgs - The minimum number of args
Returns:
the SubCommand, useful for chaining.

getHandler

public SubHandler getHandler()
Get the currently set SubHandler.

Returns:
the SubHandler which is called when this command executes.

setHandler

public SubCommand setHandler(SubHandler handler)
Set the SubHandler.

Parameters:
handler - A SubHandler which is called when this command executes.
Returns:
the SubCommand, useful for chaining.

getName

public String getName()
Get the command's name.

Returns:
The command's name.

getUsage

public String getUsage()
Get the usage string.

Returns:
The usage string.

setUsage

public SubCommand setUsage(String usage)
Set this command's usage string. The usage string describes the parameters to this command in a visual manner, for display to the user.

Parameters:
usage - a usage string.
Returns:
the SubCommand, useful for chaining.

getDescription

public String getDescription()
Get the command's description.

Returns:
The command's description.

setDescription

public SubCommand setDescription(String description)
Set the command's description. Command description should be a short blurb (one line) explaining what the command does. Long descriptions will probably wrap poorly. .

Parameters:
description - Description text.
Returns:
the SubCommand, useful for chaining.

getPermission

public String getPermission()
Get the permission node this command is required to use.

Returns:
permission node, or null if no permission.

checkPermission

public boolean checkPermission(org.bukkit.command.CommandSender sender)
Check if a Player/CommandSender has the requisite permission for this command.

Parameters:
sender - a ConsoleSender or Player.
Returns:
True if the user has the permission or the command has no permission set, false otherwise.


Copyright © 2013. All Rights Reserved.