Package me.efekos.simpler.commands
Class CommandManager
java.lang.Object
me.efekos.simpler.commands.CommandManager
Static command manager for registering commands.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
registerBaseCommand
(org.bukkit.plugin.java.JavaPlugin plugin, Class<? extends BaseCommand> command) Registers one base commandstatic void
registerBaseCommands
(org.bukkit.plugin.java.JavaPlugin plugin, Class<? extends BaseCommand>... commands) Registers multipleBaseCommand
s at the same time.static void
registerCommandTree
(org.bukkit.plugin.java.JavaPlugin plugin, CommandTree tree) Creates a command out of the tree and executes it.static void
registerCoreCommand
(org.bukkit.plugin.java.JavaPlugin plugin, Class<? extends CoreCommand> command) Deprecated.static void
registerCoreCommand
(org.bukkit.plugin.java.JavaPlugin plugin, Class<? extends CoreCommand> command, Class<? extends SubCommand>... subCommands) Registers aCoreCommand
with its children beingSubCommand
s given.
-
Constructor Details
-
CommandManager
public CommandManager()Creates a newCommandManager
, well, if you somehow need one.
-
-
Method Details
-
registerBaseCommands
@SafeVarargs public static void registerBaseCommands(org.bukkit.plugin.java.JavaPlugin plugin, Class<? extends BaseCommand>... commands) throws NoSuchFieldException, IllegalAccessException, NoSuchMethodException, InvocationTargetException, InstantiationException, InvalidAnnotationException Registers multipleBaseCommand
s at the same time.- Parameters:
plugin
- An Instance of your plugin that is using this API. If called within plugin main class, provide this keywordcommands
- A class reference of every base command to be registered- Throws:
NoSuchFieldException
- If there is no commandMap, which is not usual in a healthy server.IllegalAccessException
- If we can't access commandFieldNoSuchMethodException
- If there is no constructor in one of the command classes, or creating a new Instance of a command class failsInvocationTargetException
- If creating a new Instance of command failsInstantiationException
- If creating a new Instance of command failsInvalidAnnotationException
- If one of the commands does not have a @Command
annotation
-
registerBaseCommand
public static void registerBaseCommand(org.bukkit.plugin.java.JavaPlugin plugin, Class<? extends BaseCommand> command) throws NoSuchFieldException, IllegalAccessException, NoSuchMethodException, InvocationTargetException, InstantiationException, InvalidAnnotationException Registers one base command- Parameters:
plugin
- An Instance of your plugin that is using this API. If called within plugin main class, provide this keywordcommand
- a class reference of the base command class.- Throws:
NoSuchFieldException
- If there is no commandMap, which is not usual in a healthy server.IllegalAccessException
- If we can't access commandFieldNoSuchMethodException
- If there is no constructor in command parameter, or creating a new Instance of command failsInvocationTargetException
- If creating a new Instance of command failsInstantiationException
- If creating a new Instance of command failsInvalidAnnotationException
- If given command class does not have a @Command
annotation
-
registerCoreCommand
@Deprecated public static void registerCoreCommand(org.bukkit.plugin.java.JavaPlugin plugin, Class<? extends CoreCommand> command) throws InvalidAnnotationException, NoSuchFieldException, IllegalAccessException, NoSuchMethodException Deprecated.If you want to use this method, you have to include sub commands yourself, usingregisterCoreCommand(JavaPlugin, Class, Class[])
Registers aCoreCommand
.- Parameters:
plugin
- an instance of yourJavaPlugin
.command
- theCoreCommand
that you want to register- Throws:
InvalidAnnotationException
- if the givenCoreCommand
does not have a @Command
annotationNoSuchFieldException
- If there is no commandMap, which is not usual in a healthy server.IllegalAccessException
- If we can't access commandFieldNoSuchMethodException
- If there is no constructor in theCoreCommand
given, or creating a new instance of command fails.
-
registerCoreCommand
@SafeVarargs public static void registerCoreCommand(org.bukkit.plugin.java.JavaPlugin plugin, Class<? extends CoreCommand> command, Class<? extends SubCommand>... subCommands) throws InvalidAnnotationException, NoSuchFieldException, IllegalAccessException, NoSuchMethodException Registers aCoreCommand
with its children beingSubCommand
s given.- Parameters:
plugin
- an instance of yourJavaPlugin
.command
- theCoreCommand
that you want to registersubCommands
- An array ofSubCommand
s thisCoreCommand
will contain.- Throws:
InvalidAnnotationException
- if the givenCoreCommand
does not have a @Command
annotationNoSuchFieldException
- If there is no commandMap, which is not usual in a healthy server.IllegalAccessException
- If we can't access commandFieldNoSuchMethodException
- If there is no constructor in theCoreCommand
given, or creating a new instance of command fails.
-
registerCommandTree
public static void registerCommandTree(org.bukkit.plugin.java.JavaPlugin plugin, CommandTree tree) throws NoSuchFieldException, IllegalAccessException Creates a command out of the tree and executes it.- Parameters:
plugin
- an instance of yourJavaPlugin
.tree
- AnyCommandTree
.- Throws:
NoSuchFieldException
- If there is no commandMap, which is not usual in a healthy server.IllegalAccessException
- If we can't access commandField
-
registerCoreCommand(JavaPlugin, Class, Class[])