Java Code Examples for org.spongepowered.api.Sponge#getCommandManager()

The following examples show how to use org.spongepowered.api.Sponge#getCommandManager() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UCCommands.java    From UltimateChat with GNU General Public License v3.0 6 votes vote down vote up
UCCommands(UChat plugin) {
    manager = Sponge.getCommandManager();

    unregisterCmd("uchat");
    manager.register(plugin, uchat(), "ultimatechat", "uchat", "chat");

    if (UChat.get().getConfig().root().tell.enable) {
        registerTellAliases();
    }
    if (UChat.get().getConfig().root().broadcast.enable) {
        registerUbroadcastAliases();
    }
    registerChannelAliases();
    registerUmsgAliases();
    registerChAliases();
}
 
Example 2
Source File: ChangeSkinSponge.java    From ChangeSkin with MIT License 6 votes vote down vote up
@Listener
public void onInit(GameInitializationEvent initEvent) {
    if (!initialized)
        return;

    CommandManager cmdManager = Sponge.getCommandManager();

    //command and event register
    cmdManager.register(this, injector.getInstance(SelectCommand.class).buildSpec(), "skin-select", "skinselect");
    cmdManager.register(this, injector.getInstance(InfoCommand.class).buildSpec(), "skin-info");
    cmdManager.register(this, injector.getInstance(UploadCommand.class).buildSpec(), "skin-upload");
    cmdManager.register(this, injector.getInstance(SetCommand.class).buildSpec(), "changeskin", "setskin", "skin");
    cmdManager.register(this, injector.getInstance(InvalidateCommand.class)
            .buildSpec(), "skininvalidate", "skin-invalidate");

    Sponge.getEventManager().registerListeners(this, injector.getInstance(LoginListener.class));

    //incoming channel
    ChannelRegistrar channelReg = Sponge.getChannelRegistrar();
    String updateChannelName = new NamespaceKey(ARTIFACT_ID, UPDATE_SKIN_CHANNEL).getCombinedName();
    String permissionChannelName = new NamespaceKey(ARTIFACT_ID, CHECK_PERM_CHANNEL).getCombinedName();
    RawDataChannel updateChannel = channelReg.getOrCreateRaw(this, updateChannelName);
    RawDataChannel permChannel = channelReg.getOrCreateRaw(this, permissionChannelName);
    updateChannel.addListener(Type.SERVER, injector.getInstance(UpdateSkinListener.class));
    permChannel.addListener(Type.SERVER, injector.getInstance(CheckPermissionListener.class));
}
 
Example 3
Source File: UnknowncommandListener.java    From UltimateCore with MIT License 5 votes vote down vote up
@Listener(order = Order.LAST)
public void onCommand(SendCommandEvent event) {
    CommandSource p = event.getCause().first(CommandSource.class).orElse(null);
    if (p == null) return;
    CommandManager cm = Sponge.getCommandManager();
    if (cm.get(event.getCommand()).isPresent()) return;

    //Send message
    event.setCancelled(true);
    Messages.send(p, "unknowncommand.message");
}
 
Example 4
Source File: UCCommandService.java    From UltimateCore with MIT License 5 votes vote down vote up
@Override
public void registerLateCommands() {
    CommandManager cm = Sponge.getCommandManager();
    getUnregisteredCommands().forEach((cmd, run) -> {
        for (String alias : cmd.getAliases()) {
            cm.get(alias).ifPresent(cm::removeMapping);
        }
        register(cmd);
        run.run();
    });
    this.commandsLater.clear();
}
 
Example 5
Source File: VirtualChestCommandManager.java    From VirtualChest with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void init()
{
    CommandManager commandManager = Sponge.getCommandManager();
    commandManager.register(this.plugin, this.get(), "virtualchest", "vchest", "vc");
}