Package me.efekos.simpler.commands
Class CommandManager
java.lang.Object
me.efekos.simpler.commands.CommandManager
Static command manager for registering commands.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidregisterBaseCommand(org.bukkit.plugin.java.JavaPlugin plugin, Class<? extends BaseCommand> command) Registers one base commandstatic voidregisterBaseCommands(org.bukkit.plugin.java.JavaPlugin plugin, Class<? extends BaseCommand>... commands) Registers multipleBaseCommands at the same time.static voidregisterCommandTree(org.bukkit.plugin.java.JavaPlugin plugin, CommandTree tree) Creates a command out of the tree and executes it.static voidregisterCoreCommand(org.bukkit.plugin.java.JavaPlugin plugin, Class<? extends CoreCommand> command) Deprecated.static voidregisterCoreCommand(org.bukkit.plugin.java.JavaPlugin plugin, Class<? extends CoreCommand> command, Class<? extends SubCommand>... subCommands) Registers aCoreCommandwith its children beingSubCommands 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 multipleBaseCommands 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 @Commandannotation
-
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 @Commandannotation
-
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- theCoreCommandthat you want to register- Throws:
InvalidAnnotationException- if the givenCoreCommanddoes not have a @CommandannotationNoSuchFieldException- 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 theCoreCommandgiven, 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 aCoreCommandwith its children beingSubCommands given.- Parameters:
plugin- an instance of yourJavaPlugin.command- theCoreCommandthat you want to registersubCommands- An array ofSubCommands thisCoreCommandwill contain.- Throws:
InvalidAnnotationException- if the givenCoreCommanddoes not have a @CommandannotationNoSuchFieldException- 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 theCoreCommandgiven, 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[])