use of io.github.nucleuspowered.nucleus.internal.messages.MessageProvider in project Nucleus by NucleusPowered.
the class PowertoolCommand method viewPowertool.
private CommandResult viewPowertool(Player src, PowertoolUserDataModule user, ItemStack item) {
Optional<List<String>> cmds = user.getPowertoolForItem(item.getType());
MessageProvider mp = plugin.getMessageProvider();
if (cmds.isPresent() && !cmds.get().isEmpty()) {
Util.getPaginationBuilder(src).contents(cmds.get().stream().map(f -> Text.of(TextColors.YELLOW, f)).collect(Collectors.toList())).title(mp.getTextMessageWithTextFormat("command.powertool.viewcmdstitle", Text.of(item), Text.of(item.getType().getId()))).sendTo(src);
} else {
src.sendMessage(mp.getTextMessageWithTextFormat("command.powertool.nocmds", Text.of(item)));
}
return CommandResult.success();
}
use of io.github.nucleuspowered.nucleus.internal.messages.MessageProvider in project Nucleus by NucleusPowered.
the class TogglePowertoolCommand method executeCommand.
@Override
public CommandResult executeCommand(Player src, CommandContext args) throws Exception {
PowertoolUserDataModule user = Nucleus.getNucleus().getUserDataManager().getUnchecked(src).get(PowertoolUserDataModule.class);
// If specified - get the key. Else, the inverse of what we have now.
boolean toggle = args.<Boolean>getOne(toggleKey).orElse(!user.isPowertoolToggled());
user.setPowertoolToggle(toggle);
MessageProvider mp = plugin.getMessageProvider();
src.sendMessage(mp.getTextMessageWithFormat("command.powertool.toggle", mp.getMessageWithFormat(toggle ? "standard.enabled" : "standard.disabled")));
return CommandResult.success();
}
use of io.github.nucleuspowered.nucleus.internal.messages.MessageProvider in project Nucleus by NucleusPowered.
the class ListWarpCommand method createMain.
private void createMain(final CommandSource src, final Map<WarpCategory, List<Warp>> warps) {
List<Text> lt = warps.keySet().stream().filter(Objects::nonNull).sorted(Comparator.comparing(WarpCategory::getId)).map(s -> {
Text.Builder t = Text.builder("> ").color(TextColors.GREEN).style(TextStyles.ITALIC).append(s.getDisplayName()).onClick(TextActions.executeCallback(source -> createSub(source, s, warps)));
s.getDescription().ifPresent(x -> t.append(Text.of(" - ")).append(Text.of(TextColors.RESET, TextStyles.NONE, x)));
return t.build();
}).collect(Collectors.toList());
// Uncategorised
if (warps.containsKey(null)) {
lt.add(Text.builder("> " + this.defaultName).color(TextColors.GREEN).style(TextStyles.ITALIC).onClick(TextActions.executeCallback(source -> createSub(source, null, warps))).build());
}
MessageProvider messageProvider = plugin.getMessageProvider();
Util.getPaginationBuilder(src).header(messageProvider.getTextMessageWithFormat("command.warps.list.headercategory")).title(messageProvider.getTextMessageWithFormat("command.warps.list.maincategory")).padding(Text.of(TextColors.GREEN, "-")).contents(lt).sendTo(src);
}
Aggregations