Class CommandManager
java.lang.Object
de.gurkenlabs.litiengine.util.CommandManager
- All Implemented Interfaces:
ILaunchable
Manages the binding and execution of commands. Implements the ILaunchable interface to provide start and terminate functionality.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidBinds a command to a specific consumer.booleanexecuteCommand(String command) Executes a command by finding the corresponding consumer and passing the command arguments to it.voidstart()Starts the operation of this instance.voidTerminates the operation of this instance.
-
Constructor Details
-
CommandManager
public CommandManager()Constructs a new CommandManager. Initializes the commandConsumers map and the commandListener.
-
-
Method Details
-
bind
Binds a command to a specific consumer. If the command is already bound, an IllegalArgumentException is thrown.- Parameters:
command- the command to bindcommandConsumer- the consumer to bind to the command- Throws:
IllegalArgumentException- if the command is already bound
-
executeCommand
Executes a command by finding the corresponding consumer and passing the command arguments to it. If the command is null, empty, or not bound to any consumer, it returns false.- Parameters:
command- the command to execute- Returns:
- true if the command was successfully executed, false otherwise
-
start
public void start()Description copied from interface:ILaunchableStarts the operation of this instance.- Specified by:
startin interfaceILaunchable
-
terminate
public void terminate()Description copied from interface:ILaunchableTerminates the operation of this instance.- Specified by:
terminatein interfaceILaunchable
-