Search in sources :

Example 1 with SpongeParameterizedCommand

use of org.spongepowered.common.command.SpongeParameterizedCommand in project SpongeCommon by SpongePowered.

the class SpongeParameterizedCommandRegistrar method register.

@Override
@NonNull
public CommandMapping register(@NonNull final PluginContainer container, final Command.@NonNull Parameterized command, @NonNull final String primaryAlias, @NonNull final String@NonNull ... secondaryAliases) throws CommandFailedRegistrationException {
    // Get the builder and the first literal.
    final String namespacedCommand = container.metadata().id() + ":" + primaryAlias.toLowerCase(Locale.ROOT);
    final ArrayList<String> aliases = new ArrayList<>();
    aliases.add(primaryAlias);
    aliases.addAll(Arrays.asList(secondaryAliases));
    // This will throw an error if there is an issue.
    final CommandMapping mapping = this.commandManager().registerAliasWithNamespacing(this, container, namespacedCommand, aliases, null);
    this.createNode(mapping, command).forEach(this.commandManager().getDispatcher()::register);
    ((SpongeParameterizedCommand) command).setCommandManager(this.commandManager());
    this.commandMap.put(mapping, command);
    return mapping;
}
Also used : CommandMapping(org.spongepowered.api.command.manager.CommandMapping) SpongeParameterizedCommand(org.spongepowered.common.command.SpongeParameterizedCommand) ArrayList(java.util.ArrayList) NonNull(org.checkerframework.checker.nullness.qual.NonNull)

Aggregations

ArrayList (java.util.ArrayList)1 NonNull (org.checkerframework.checker.nullness.qual.NonNull)1 CommandMapping (org.spongepowered.api.command.manager.CommandMapping)1 SpongeParameterizedCommand (org.spongepowered.common.command.SpongeParameterizedCommand)1