Менеджер команд

The CommandManager stands as the manager for watching what commands get typed into chat, and redirecting them to the right command handler. To register your command, use the method CommandManager#register(Object, CommandCallable, String…) passing your plugin, an instance of the command, and any needed aliases as parameters.

Usually you want to register your commands when the GameInitializationEvent is called.

import org.spongepowered.api.Sponge;
import org.spongepowered.api.command.CommandManager;

PluginContainer plugin = ...;

CommandManager cmdManager = Sponge.getCommandManager();
cmdManager.register(plugin, myCommandSpec, "alias1", "alias2", "alias3");

Примечание

Аргументы после указания экземпляра команды являются дополнительными вариантами для регистрации команды. Вы можете добавить столько, сколько вы хотите. Первый вариант, который не используется другой командой становится основным. Это означает, что варианты используемые другой командой игнорируются.

The CommandManager can also be used to call a command programmatically:

cmdManager.process(player, "msg Notch hi notch!");

Вы также можете отправить команду из консоли сервера:

cmdManager.process(Sponge.getServer().getConsole(), "kill Notch");