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 CommandListener
Modifier and Type | Method and Description |
---|---|
(package private) BaseCommand.CommandResult |
execute(java.lang.String command,
java.lang.String args,
BaseCommand.CommandContext context)
Called when your
declares that it wants to take over execution of a command. |
(package private) void |
onPostExecute(java.lang.String command,
java.lang.String args,
BaseCommand.CommandResult result,
BaseCommand.CommandContext context,
CommandListener interceptedBy)
Called after a command is run, regardless of whether execution was intercepted by a
or not. |
(package private) boolean |
onPreExecute(java.lang.String command,
java.lang.String args,
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.
|
boolean onPreExecute(@NotNull java.lang.String command, @NotNull java.lang.String args, @NotNull 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
- org.jetbrains.dokka.NodeRenderContent@229e50aa: The command that is about to be run. Will always be lowercase.args
- org.jetbrains.dokka.NodeRenderContent@4377e608: The arguments passed into the command.context
- org.jetbrains.dokka.NodeRenderContent@46f76d2: The current console enum BaseCommand.CommandContext
.alreadyIntercepted
- org.jetbrains.dokka.NodeRenderContent@56a69dfe: 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.BaseCommand.CommandResult execute(@NotNull java.lang.String command, @NotNull java.lang.String args, @NotNull 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
- org.jetbrains.dokka.NodeRenderContent@7a567de3: The command to be executed. Will always be lowercase.args
- org.jetbrains.dokka.NodeRenderContent@5f04d9d: The arguments passed into the command.context
- org.jetbrains.dokka.NodeRenderContent@675b69b0: 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 BaseCommand.CommandResult result, @NotNull 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
- org.jetbrains.dokka.NodeRenderContent@44c8ad76: The command that was executed. Will always be lowercase.args
- org.jetbrains.dokka.NodeRenderContent@43d39cd7: The arguments passed into the command.result
- org.jetbrains.dokka.NodeRenderContent@7ff97bf4: The result of the command's execution.context
- org.jetbrains.dokka.NodeRenderContent@310d8614: The current console enum BaseCommand.CommandContext
.interceptedBy
- org.jetbrains.dokka.NodeRenderContent@30af2e5e: 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