Дочерние команды
Построитель CommandSpec поддерживает иерархию команд, например, такого вида:
- /mail(родительская команда)- /mail send(дочерняя команда)
- /mail read(дочерняя команда)
 
Каждая дочерняя команда является отдельным объектом типа CommandSpec и может быть создана таким же образом, как и любая другая команда.
import org.spongepowered.api.text.Text;
import org.spongepowered.api.command.spec.CommandSpec;
// /mail read
CommandSpec readCmd = CommandSpec.builder()
    .permission("myplugin.mail.read")
    .description(Text.of("Read your inbox"))
    .executor(...)
    .build();
// /mail send
CommandSpec sendCmd = CommandSpec.builder()
    .permission("myplugin.mail.send")
    .description(Text.of("Send a mail"))
    .arguments(...)
    .executor(...)
    .build();
Вместо того, чтобы регистрировать их в службе команд, дочерние команды регистрируются в своей родительской команде с помощью метода CommandSpec.Builder#child(CommandCallable, String…). Они зарегистрированы в списке псевдонимов. Первый предоставленный псевдоним является основным и появится в сообщении об использовании.
import org.spongepowered.api.Sponge;
CommandSpec mailCommandSpec = CommandSpec.builder()
    .permission("myplugin.mail")
    .description(Text.of("Send and receive mails"))
    .child(readCmd, "read", "r", "inbox")
    .child(sendCmd, "send", "s", "write")
    .build();
Sponge.getCommandManager().register(plugin, mailCommandSpec, "mail", "email");
Примечание
If a CommandExecutor was set for the parent command, it is used as a fallback if the arguments do not match one of the child command aliases. Setting an executor is not required.