use of org.spongepowered.api.command.parameter.CommandContext in project SpongeCommon by SpongePowered.
the class SpongeCommand method pluginsListSubcommand.
@NonNull
private CommandResult pluginsListSubcommand(final CommandContext context) {
final Collection<PluginContainer> plugins = Launch.instance().pluginManager().plugins();
context.sendMessage(Identity.nil(), this.title("Plugins (" + plugins.size() + ")"));
for (final PluginContainer specificContainer : plugins) {
final PluginMetadata metadata = specificContainer.metadata();
final TextComponent.Builder builder = Component.text();
this.createShortContainerMeta(builder.append(SpongeCommand.INDENT_COMPONENT), metadata);
builder.clickEvent(SpongeComponents.executeCallback(cause -> cause.sendMessage(Identity.nil(), this.createContainerMeta(metadata))));
context.sendMessage(Identity.nil(), builder.build());
}
return CommandResult.success();
}
use of org.spongepowered.api.command.parameter.CommandContext in project SpongeCommon by SpongePowered.
the class SpongeCommand method whichExecutor.
@NonNull
private CommandResult whichExecutor(final CommandContext context) {
final CommandMapping mapping = context.requireOne(this.commandMappingKey);
context.sendMessage(Identity.nil(), Component.text().append(this.title("Aliases: "), Component.join(JoinConfiguration.separator(Component.text(", ")), mapping.allAliases().stream().map(x -> Component.text(x, NamedTextColor.YELLOW)).collect(Collectors.toList())), Component.newline(), this.title("Owned by: "), this.hl(mapping.plugin().map(x -> x.metadata().name().orElseGet(() -> x.metadata().id())).orElse("unknown"))).build());
return CommandResult.success();
}
Aggregations