Hooks
This page explains how to use hooks, which allow for injecting custom logic before or after command registration, unregistration, or execution.
Last updated
Was this helpful?
This page explains how to use hooks, which allow for injecting custom logic before or after command registration, unregistration, or execution.
Last updated
Was this helpful?
Was this helpful?
var lamp = Lamp.builder()
.hooks(hooks -> {
hooks.onCommandExecuted(new MyCommandExecutedHook());
// Add other hooks as needed
})
.build();public class MyCommandExecutedHook implements CommandExecutedHook<CommandActor> {
@Override
public void onExecuted(@NotNull ExecutableCommand<CommandActor> command, @NotNull ExecutionContext<CommandActor> context, @NotNull CancelHandle cancelHandle) {
System.out.println("Command executed: " + command.path());
}
}class MyCommandExecutedHook : CommandExecutedHook<CommandActor> {
override fun onExecuted(command: ExecutableCommand<CommandActor>, context: ExecutionContext<CommandActor>, cancelHandle: CancelHandle) {
println("Command executed: ${command.path()}")
}
}