E
- The specific Plugin
to usepublic class CommandHandler<E extends org.bukkit.plugin.Plugin> extends Object implements org.bukkit.command.CommandExecutor, org.bukkit.command.TabCompleter
Plugin
Modifier and Type | Field and Description |
---|---|
protected String |
command
The primary command to access this
CommandHandler in-game |
protected Map<String,SubCommand<E>> |
commands
Private
HashMap of subcommands |
protected Lang |
name
The format for output
|
protected E |
plugin
Private
Plugin instance |
Constructor and Description |
---|
CommandHandler(E plugin,
String command)
CommandHandler constructor. |
Modifier and Type | Method and Description |
---|---|
SubCommand<E> |
getCommand(String name)
Returns a subcommand, or
null if none exists. |
Collection<SubCommand<E>> |
getCommands()
Returns all subcommands as a
Collection . |
String |
getMainCommand()
Returns the main command associated with this
CommandHandler |
boolean |
isRegistered(String name)
Checks to see if a
SubCommand is registered under the passed
command name |
boolean |
onCommand(org.bukkit.command.CommandSender sender,
org.bukkit.command.Command cmd,
String commandLabel,
String[] args)
|
List<String> |
onTabComplete(org.bukkit.command.CommandSender sender,
org.bukkit.command.Command command,
String alias,
String[] args) |
<T extends SubCommand<E>> |
registerSubCommand(T command)
Registers a
SubCommand under the main supplied command name |
<T extends SubCommand<E>> |
registerSubCommands(T... commands)
Registers multiple
SubCommand instance under the provided command
name. |
void |
unregisterSubCommand(String name)
Removes a
SubCommand in use by this handler. |
protected final Lang name
protected final E extends org.bukkit.plugin.Plugin plugin
Plugin
instanceprotected final Map<String,SubCommand<E extends org.bukkit.plugin.Plugin>> commands
HashMap
of subcommandsprotected String command
CommandHandler
in-gamepublic CommandHandler(E plugin, String command)
CommandHandler
constructor. Sets fields and registers the main
command through Bukkit to be executed by this handler.plugin
- The main Plugin
instancecommand
- The command to write subcommands underpublic boolean onCommand(org.bukkit.command.CommandSender sender, org.bukkit.command.Command cmd, String commandLabel, String[] args)
onCommand
in interface org.bukkit.command.CommandExecutor
sender
- cmd
- The command instance which was executedcommandLabel
- args
- false
public List<String> onTabComplete(org.bukkit.command.CommandSender sender, org.bukkit.command.Command command, String alias, String[] args)
onTabComplete
in interface org.bukkit.command.TabCompleter
sender
- command
- alias
- args
- public final SubCommand<E> getCommand(String name)
null
if none exists.name
- The name of the subcommandSubCommand
, or null if it does not existpublic final Collection<SubCommand<E>> getCommands()
Collection
.Collection
of all registered SubCommand
public final <T extends SubCommand<E>> T registerSubCommand(T command)
SubCommand
under the main supplied command nameT
- The subcommand typecommand
- The SubCommand
to registerIllegalArgumentException
- If the command's name is already in usepublic final <T extends SubCommand<E>> void registerSubCommands(T... commands)
SubCommand
instance under the provided command
name. If an exception is encountered, it will continue registering
commands and re-throw the exception upon method completion.T
- The subcommand typecommands
- The SubCommand
instances to registerIllegalArgumentException
- If the command's name is already in usepublic void unregisterSubCommand(String name)
SubCommand
in use by this handler. If no
SubCommand
is registered under the name, then nothing happensname
- The command to check forpublic boolean isRegistered(String name)
SubCommand
is registered under the passed
command namename
- The command to check fortrue
if registered to a SubCommand
public String getMainCommand()
CommandHandler
Copyright © 2015. All rights reserved.