use of org.spongepowered.common.command.parameter.subcommand.SpongeSubcommandParameterBuilder in project SpongeCommon by SpongePowered.
the class SpongeParameterizedCommandBuilder method build.
@Override
public Command.@NonNull Parameterized build() {
if (this.subcommands.isEmpty()) {
Preconditions.checkState(this.commandExecutor != null, "Either a subcommand or an executor must exist!");
} else {
Preconditions.checkState(!(!this.parameters.isEmpty() && this.commandExecutor == null), "An executor must exist if you set parameters!");
}
final Predicate<CommandCause> requirements = this.executionRequirements == null ? cause -> true : this.executionRequirements;
final List<Parameter.Subcommand> subcommands = this.subcommands.entrySet().stream().map(x -> new SpongeSubcommandParameterBuilder().aliases(x.getValue()).subcommand(x.getKey()).build()).collect(Collectors.toList());
// build the node.
return new SpongeParameterizedCommand(subcommands, ImmutableList.copyOf(this.parameters), this.shortDescription, this.extendedDescription, requirements, this.commandExecutor, this.flags, this.isTerminal);
}
Aggregations