public CommandListener
Provides an interface to listen for command execution, with the option to intercept the command and execute your own code instead.
Important performance note: s are persistent through the entire game session, so be careful with your memory management!interface CommandListener
interface CommandListenerboolean onPreExecute(@NotNull
java.lang.String command,
@NotNull
java.lang.String args,
@NotNull
org.lazywizard.console.BaseCommand.CommandContext context,
boolean alreadyIntercepted)
Called before a console command is executed, and gives the listener a chance to intercept execution and run its own code.
command - The command that is about to be run. Will always be lowercase.args - The arguments passed into the command.context - The current console enum BaseCommand.CommandContext.alreadyIntercepted - Whether another, higher-priority interface CommandListener has already declared they will intercept execution for this command. If true, your listener should not do anything that affects execution of the command.true if your listener will take over execution of the command from its normal implementation, false otherwise. If true, org.lazywizard.console.CommandListener$execute(java.lang.String,java.lang.String,org.lazywizard.console.BaseCommand.CommandContext) will be called by the console if your listener was the highest priority listener to request execution takeover.org.lazywizard.console.BaseCommand.CommandResult execute(@NotNull
java.lang.String command,
@NotNull
java.lang.String args,
@NotNull
org.lazywizard.console.BaseCommand.CommandContext context)
Called when your declares that it wants to take over execution of a command. interface CommandListener
This is only called if your listener returned true during and was the highest priority listener to do so.org.lazywizard.console.CommandListener$onPreExecute(java.lang.String,java.lang.String,org.lazywizard.console.BaseCommand.CommandContext,kotlin.Boolean)
command - The command to be executed. Will always be lowercase.args - The arguments passed into the command.context - The current console enum BaseCommand.CommandContext.enum BaseCommand.CommandResult describing the result of execution.interface CommandListener,
org.lazywizard.console.CommandListener$onPreExecute(java.lang.String,java.lang.String,org.lazywizard.console.BaseCommand.CommandContext,kotlin.Boolean),
BaseCommand#runCommand(String, CommandContext)void onPostExecute(@NotNull
java.lang.String command,
@NotNull
java.lang.String args,
@NotNull
org.lazywizard.console.BaseCommand.CommandResult result,
@NotNull
org.lazywizard.console.BaseCommand.CommandContext context,
@Nullable
CommandListener interceptedBy)
Called after a command is run, regardless of whether execution was intercepted by a or not.interface CommandListener
command - The command that was executed. Will always be lowercase.args - The arguments passed into the command.result - The result of the command's execution.context - The current console enum BaseCommand.CommandContext.interceptedBy - The interface CommandListener that intercepted the commands execution, if any. Will be null if no listener's org.lazywizard.console.CommandListener$onPreExecute(java.lang.String,java.lang.String,org.lazywizard.console.BaseCommand.CommandContext,kotlin.Boolean) returned true.interface CommandListener