The Command Manager

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. If you are registering the commands from the main plugin class, use this as the plugin parameter.

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

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

Notitie

De argumenten na het nieuwe exemplaar van jouw commando zijn de aliassen die geregistreerd moeten worden voor jou commando. De primaire alias wordt de eerste alias die niet wordt gebruikt door een ander commando. Dit betekend dat aliassen die gebruikt worden door een ander commando genegeerd worden.

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

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

You can also send a command from the server console:

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