Package net.citizensnpcs.api.command
Class CommandManager
java.lang.Object
net.citizensnpcs.api.command.CommandManager
- All Implemented Interfaces:
- TabCompleter
- 
Nested Class SummaryNested Classes
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidexecute(Command command, String[] args, CommandSender sender, Object... methodArgs) Attempt to execute a command using the rootCommandgiven.booleanexecuteSafe(Command command, String[] args, CommandSender sender, Object... methodArgs) A safe version ofexecute(org.bukkit.command.Command, String[], CommandSender, Object...)which catches and logs allExceptions that occur.getClosestCommandModifier(String command, String modifier) Searches for the closest modifier using Levenshtein distance to the given top level command and modifier.getCommand(String... commandParts) Gets theCommandManager.CommandInfofor the given command parts, ornullif not found.getCommands(String topLevelCommand) Gets all modified and root commands from the given root level command.booleanhasCommand(String... parts) Checks to see whether there is a command handler for the given command parts at the root level.booleanhasCommand(Command cmd, String... modifier) Checks to see whether there is a command handler for the given command at the root level.onTabComplete(CommandSender sender, Command command, String alias, String[] args) voidRegister a class that contains commands (methods annotated withCommand).voidRegisters anCommandAnnotationProcessorthat can process annotations before a command is executed.voidregisterTabCompletion(JavaPlugin plugin) voidvoidsetInjector(Injector injector) voidsetTranslationPrefixProvider(Function<Command, String> provider) 
- 
Constructor Details- 
CommandManagerpublic CommandManager()
 
- 
- 
Method Details- 
executepublic void execute(Command command, String[] args, CommandSender sender, Object... methodArgs) throws CommandException Attempt to execute a command using the rootCommandgiven. A list of method arguments may be used when calling the command handler method. A command handler method should follow the formcommand(CommandContext args, CommandSender sender)whereCommandSendercan be replaced withPlayerto only accept players. The method parameters must include the method args given, if any.- Parameters:
- command- The command to execute
- args- The arguments of the command
- sender- The sender of the command
- methodArgs- The method arguments to be used when calling the command handler
- Throws:
- CommandException- Any exceptions caused from execution of the command
 
- 
executeSafepublic boolean executeSafe(Command command, String[] args, CommandSender sender, Object... methodArgs) A safe version ofexecute(org.bukkit.command.Command, String[], CommandSender, Object...)which catches and logs allExceptions that occur.- Returns:
- Whether command usage should be printed
- See Also:
 
- 
getClosestCommandModifierSearches for the closest modifier using Levenshtein distance to the given top level command and modifier.- Parameters:
- command- The top level command
- modifier- The modifier to use as the base
- Returns:
- The closest modifier, or empty
 
- 
getCommandGets theCommandManager.CommandInfofor the given command parts, ornullif not found.- Parameters:
- commandParts- The parts of the command
- Returns:
- The command info for the command
 
- 
getCommandsGets all modified and root commands from the given root level command. For example, if /npc look and /npc jump were defined, callinggetCommands("npc")would returnCommandManager.CommandInfos for both commands.- Parameters:
- topLevelCommand- The root level command
- Returns:
- The list of CommandManager.CommandInfos
 
- 
hasCommandChecks to see whether there is a command handler for the given command at the root level. This will check aliases as well.- Parameters:
- cmd- The command to check
- modifier- The modifier to check (may be empty)
- Returns:
- Whether the command is handled
 
- 
hasCommandChecks to see whether there is a command handler for the given command parts at the root level. This will check aliases as well.- Parameters:
- parts- The parts to check (must not be empty)
- Returns:
- Whether the command is handled
 
- 
onTabCompletepublic List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) - Specified by:
- onTabCompletein interface- TabCompleter
 
- 
registerRegister a class that contains commands (methods annotated withCommand). If no dependencyInjectoris specified, then only static methods of the class will be registered. Otherwise, new instances the command class will be created and instance methods will be called.- Parameters:
- clazz- The class to scan
- See Also:
 
- 
registerAnnotationProcessorRegisters anCommandAnnotationProcessorthat can process annotations before a command is executed. Methods with theCommandannotation will have the rest of their annotations scanned and stored if there is a matchingCommandAnnotationProcessor. Annotations that do not have a processor are discarded. The scanning method uses annotations from the declaring class as a base before narrowing using the method's annotations.- Parameters:
- processor- The annotation processor
 
- 
registerTabCompletion
- 
setDefaultDurationUnits
- 
setInjector
- 
setTranslationPrefixProvider
 
-