Package pro.gravit.utils.command
Class CommandHandler
java.lang.Object
pro.gravit.utils.command.CommandHandler
- All Implemented Interfaces:
Runnable
- Direct Known Subclasses:
JLineCommandHandler,StdCommandHandler
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic interface -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final CommandCategoryprotected final List<CommandHandler.Category> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCommandHandler(List<CommandHandler.Category> categories, CommandCategory baseCategory) -
Method Summary
Modifier and TypeMethodDescriptionabstract voidbell()If supported, sends a bell signal to the consoleabstract voidclear()Cleans the consolevoidvoidvoidevalNative(String line, boolean bell) findCategory(String name) findCommand(String name) abstract StringreadLine()Reads a line from the consolevoidregisterCategory(CommandHandler.Category category) voidregisterCommand(String name, Command command) voidrun()voidunregisterCategory(CommandHandler.Category category) unregisterCommand(String name) voidwalk(CommandHandler.CommandWalk callback) Walk all categories Categories are sorted in the order they are added.
-
Field Details
-
categories
-
baseCategory
-
-
Constructor Details
-
CommandHandler
public CommandHandler() -
CommandHandler
-
-
Method Details
-
eval
-
evalNative
- Throws:
Exception
-
eval
- Throws:
Exception
-
lookup
- Throws:
CommandException
-
findCommand
-
readLine
Reads a line from the console- Returns:
- command line
- Throws:
IOException- Internal Error
-
registerCommand
-
registerCategory
-
unregisterCategory
-
findCategory
-
unregisterCommand
-
run
public void run() -
walk
Walk all categories Categories are sorted in the order they are added. The base category is walked last- Parameters:
callback- your callback
-
getBaseCategory
-
getCategories
-
bell
public abstract void bell()If supported, sends a bell signal to the console -
clear
Cleans the console- Throws:
IOException- Internal Error
-