use of org.spongepowered.api.command.CommandResult in project Nucleus by NucleusPowered.
the class CheckNotesCommand method executeCommand.
@Override
public CommandResult executeCommand(CommandSource src, CommandContext args) throws Exception {
User user = args.<User>getOne(playerKey).get();
List<NoteData> notes = handler.getNotesInternal(user);
if (notes.isEmpty()) {
src.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("command.checknotes.none", user.getName()));
return CommandResult.success();
}
List<Text> messages = notes.stream().sorted(Comparator.comparing(NoteData::getDate)).map(x -> createMessage(x, user)).collect(Collectors.toList());
messages.add(0, plugin.getMessageProvider().getTextMessageWithFormat("command.checknotes.info"));
PaginationService paginationService = Sponge.getGame().getServiceManager().provideUnchecked(PaginationService.class);
paginationService.builder().title(Text.builder().color(TextColors.GOLD).append(Text.of(plugin.getMessageProvider().getMessageWithFormat("command.checknotes.header", user.getName()))).build()).padding(Text.builder().color(TextColors.YELLOW).append(Text.of("=")).build()).contents(messages).sendTo(src);
return CommandResult.success();
}
use of org.spongepowered.api.command.CommandResult in project Nucleus by NucleusPowered.
the class CheckMutedCommand method executeCommand.
@Override
protected CommandResult executeCommand(CommandSource src, CommandContext args) throws Exception {
// Using the cache, tell us who is jailed.
MessageProvider provider = plugin.getMessageProvider();
List<UUID> usersInMute = plugin.getUserCacheService().getMuted();
if (usersInMute.isEmpty()) {
src.sendMessage(provider.getTextMessageWithFormat("command.checkmuted.none"));
return CommandResult.success();
}
// Get the users in this jail, or all jails
Util.getPaginationBuilder(src).title(provider.getTextMessageWithFormat("command.checkmuted.header")).contents(usersInMute.stream().map(x -> {
Text name = plugin.getNameUtil().getName(x).orElseGet(() -> Text.of("unknown: ", x.toString()));
return name.toBuilder().onHover(TextActions.showText(provider.getTextMessageWithFormat("command.checkmuted.hover"))).onClick(TextActions.runCommand("/nucleus:checkmute " + x.toString())).build();
}).collect(Collectors.toList())).sendTo(src);
return CommandResult.success();
}
Aggregations