Interface CommandExecutor

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface CommandExecutor
Functional interface for command execution logic.

Implementations receive a CommandContext containing all parsed arguments and the command sender, and return a CommandResult indicating the outcome.

Example Usage


 CommandExecutor executor = ctx -> {
     String name = ctx.getArgument("name", String.class);
     ctx.getSender().sendMessage("Hello, " + name + "!");
     return CommandResult.SUCCESS;
 };
 
  • Method Summary

    Modifier and Type
    Method
    Description
    Executes the command with the given context.
  • Method Details

    • execute

      Executes the command with the given context.
      Parameters:
      context - the command context containing sender and arguments
      Returns:
      the result of the command execution
      Throws:
      CommandException - if the command fails due to invalid arguments or state