Package me.despical.commandframework
Class CommandFramework
java.lang.Object
me.despical.commandframework.CommandFramework
- All Implemented Interfaces:
org.bukkit.command.CommandExecutor,org.bukkit.command.TabCompleter
Main class of the framework to register commands, add tab
completions and implement a function to run if there is no
matched commands related this framework.
- Since:
- 1.0.0
- Author:
- Despical
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static CommandFrameworkprotected ParameterHandlerprotected final org.bukkit.plugin.Plugin -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal <A,B extends A>
voidaddCustomParameter(@NotNull String value, @NotNull Function<CommandArguments, B> function) Adds a custom parameter to the parameter handler.Get a copy of registered commands and sub-commands.Get a copy of registered commands.static CommandFrameworkfinal @NotNull LoggerReturns the logger instance of Command Framework.Get a copy of registered sub-commands-.booleanonCommand(@NotNull org.bukkit.command.CommandSender sender, org.bukkit.command.Command cmd, @NotNull String label, String[] args) onTabComplete(@NotNull org.bukkit.command.CommandSender sender, org.bukkit.command.Command cmd, @NotNull String label, String[] args) final OptionManageroptions()Returns the option manager.final voidregisterCommands(@NotNull Object instance) Registers commands in given object's class.protected final voidsetCommandMap(org.bukkit.command.CommandMap commandMap) final voidChanges default loggerfinal voidunregisterCommand(@NotNull String commandName) Unregisters command and tab completer if there is with the given name.final voidUnregisters all of registered commands and tab completers using that instance.
-
Field Details
-
instance
-
plugin
protected final org.bukkit.plugin.Plugin plugin -
parameterHandler
-
-
Constructor Details
-
CommandFramework
public CommandFramework(@NotNull @NotNull org.bukkit.plugin.Plugin plugin)
-
-
Method Details
-
registerCommands
Registers commands in given object's class.- Parameters:
instance- the class instance of given object.
-
unregisterCommand
Unregisters command and tab completer if there is with the given name.- Parameters:
commandName- name of the command that's going to be removed
-
unregisterCommands
public final void unregisterCommands()Unregisters all of registered commands and tab completers using that instance. -
addCustomParameter
public final <A,B extends A> void addCustomParameter(@NotNull @NotNull String value, @NotNull @NotNull Function<CommandArguments, B> function) Adds a custom parameter to the parameter handler.This method allows the addition of a custom parameter to the parameter handler by specifying a value and a function that converts
CommandArgumentsto an instance of a type that extendsCommandFramework.- Type Parameters:
A- the type of the parent class that the custom parameter's type extendsB- the type of the custom parameter, which extendsCommandFramework- Parameters:
value- the value to call custom parameter using @Param, must not be null, can be a class namefunction- a function that takesCommandArgumentsand returns an instance ofCommandFramework, must not be null- Throws:
NullPointerException- ifvalueis already added as a custom parameter
-
getLogger
Returns the logger instance of Command Framework. By default, logger isplugin's logger.- Returns:
- the current logger instance.
- Since:
- 1.4.8
-
setLogger
Changes default logger- Parameters:
logger- the non-null new logger instance- Since:
- 1.4.8
-
options
Returns the option manager.- Returns:
- the option manager.
- Since:
- 1.4.8
-
setCommandMap
protected final void setCommandMap(org.bukkit.command.CommandMap commandMap) -
getCommands
Get a copy of registered commands.- Returns:
- list of the commands.
-
getSubCommands
Get a copy of registered sub-commands-.- Returns:
- list of the sub-commands.
-
getAllCommands
Get a copy of registered commands and sub-commands.- Returns:
- list of the commands and sub-commands.
-
getInstance
-
onCommand
public boolean onCommand(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull org.bukkit.command.Command cmd, @NotNull @NotNull String label, String[] args) - Specified by:
onCommandin interfaceorg.bukkit.command.CommandExecutor
-
onTabComplete
public List<String> onTabComplete(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull org.bukkit.command.Command cmd, @NotNull @NotNull String label, String[] args) - Specified by:
onTabCompletein interfaceorg.bukkit.command.TabCompleter
-