Komut Yöneticisi

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");

Not

Komutunuzun yeni örneğinden sonraki değişkenler komuta kaydolmak için takma adlardır. İstediğiniz kadar metinler ekleyebilirsiniz. Başka bir komut tarafından kullanılmayan ilk takma ad birincil takma ad olur. Bu, başka bir komut tarafından kullanılan takma adların yok sayıldığı anlamına gelir.

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

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

Sunucu konsolundan bir komut gönderebilirsiniz:

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