Is it possible to use the same class as a command executor for multiple commands?

I’ve setup multiple child commands to use the same CommandExecutor class but I can’t find a way to tell exactly which command was sent in the execute method. I’ve dug through documentation and debug variables but can’t find anything useful. These commands do very little and are somewhat similar so it doesn’t make sense to have a ton of classes for one liners. Thanks for all the help.

Instead of using child commands use one command with a variety of command arguments.

You don’t have to make “tons of classes”, you can use pseudo-delegate:

public CommandResult executehw(CommandSource src, CommandContext args) throws CommandException
{
src.sendMessage(Texts.of(“Hello World!”));
return CommandResult.success();
}

@Listener
public void onGameInitialization(GameInitializationEvent event)
{
CommandSpec myCommandSpec = CommandSpec.builder()
.description(Texts.of(“Hello World Command”))
.permission(“myplugin.command.helloworld”)
.executor(this::executehw)
.build();
game.getCommandManager().register(this, myCommandSpec, “helloworld”, “hello”, “test”);
}