use of io.github.nucleuspowered.nucleus.internal.messages.MessageProvider 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();
}
use of io.github.nucleuspowered.nucleus.internal.messages.MessageProvider in project Nucleus by NucleusPowered.
the class MessagesUpdateCommand method executeCommand.
@Override
public CommandResult executeCommand(CommandSource src, CommandContext args) throws Exception {
// First, reload the messages.
boolean reload = this.plugin.reloadMessages();
if (!reload) {
// There was a failure loading a custom file
throw ReturnMessageException.fromKey("command.nucleus.messageupdate.couldnotload");
}
MessageProvider messageProvider = plugin.getMessageProvider();
if (!(messageProvider instanceof ConfigMessageProvider)) {
throw new ReturnMessageException(messageProvider.getTextMessageWithFormat("command.nucleus.messageupdate.notfile"));
}
ConfigMessageProvider cmp = (ConfigMessageProvider) messageProvider;
List<String> keys = cmp.checkForMigration();
src.sendMessage(messageProvider.getTextMessageWithFormat("command.nucleus.messageupdate.reloaded"));
if (keys.isEmpty()) {
return CommandResult.success();
}
if (args.hasAny("y")) {
cmp.reset(keys);
src.sendMessage(messageProvider.getTextMessageWithFormat("command.nucleus.messageupdate.reset"));
} else {
src.sendMessage(messageProvider.getTextMessageWithFormat("command.nucleus.messageupdate.sometoupdate", String.valueOf(keys.size())));
keys.forEach(x -> src.sendMessage(Text.of(TextColors.YELLOW, x)));
src.sendMessage(messageProvider.getTextMessageWithFormat("command.nucleus.messageupdate.confirm", "/nucleus update-messages -y").toBuilder().onClick(TextActions.runCommand("/nucleus update-messages -y")).build());
}
return CommandResult.success();
}
use of io.github.nucleuspowered.nucleus.internal.messages.MessageProvider in project Nucleus by NucleusPowered.
the class ChatListener method createReplacements.
private static Map<String, Tuple<String[], Function<String, String>>> createReplacements() {
Map<String, Tuple<String[], Function<String, String>>> t = new HashMap<>();
MessageProvider mp = Nucleus.getNucleus().getMessageProvider();
BiFunction<String, String, String> fss = (key, s) -> s.replaceAll("[&]+[" + key.toLowerCase() + key.toUpperCase() + "]", "");
NameUtil.getColours().forEach((key, value) -> {
t.put("&" + key, Tuple.of(new String[] { prefix + "colour." + value.getName(), prefix + "color." + value.getName() }, s -> fss.apply(key.toString(), s)));
permissionToDesc.put(prefix + "colour." + value.getName(), mp.getMessageWithFormat("permission.chat.colourspec", value.getName().toLowerCase(), key.toString()));
permissionToDesc.put(prefix + "color." + value.getName(), mp.getMessageWithFormat("permission.chat.colorspec", value.getName().toLowerCase(), key.toString()));
});
NameUtil.getStyleKeys().entrySet().stream().filter(x -> x.getKey() != 'k').forEach((k) -> {
t.put("&" + k.getKey(), Tuple.of(new String[] { prefix + "style." + k.getValue().toLowerCase() }, s -> fss.apply(k.getKey().toString(), s)));
permissionToDesc.put(prefix + "style." + k.getValue().toLowerCase(), mp.getMessageWithFormat("permission.chat.stylespec", k.getValue().toLowerCase(), k.getKey().toString()));
});
t.put("&k", Tuple.of(new String[] { prefix + "magic" }, s -> s.replaceAll("[&]+[kK]", "")));
return t;
}
use of io.github.nucleuspowered.nucleus.internal.messages.MessageProvider in project Nucleus by NucleusPowered.
the class JailHandler method onJail.
public void onJail(JailData md, Player user) {
MessageProvider provider = Nucleus.getNucleus().getMessageProvider();
if (md.getEndTimestamp().isPresent()) {
user.sendMessage(provider.getTextMessageWithFormat("jail.playernotify.time", Util.getTimeStringFromSeconds(Instant.now().until(md.getEndTimestamp().get(), ChronoUnit.SECONDS))));
} else {
user.sendMessage(provider.getTextMessageWithFormat("jail.playernotify.standard"));
}
user.sendMessage(provider.getTextMessageWithFormat("standard.reasoncoloured", md.getReason()));
}
use of io.github.nucleuspowered.nucleus.internal.messages.MessageProvider in project Nucleus by NucleusPowered.
the class ListPowertoolCommand method from.
private Text from(final PowertoolUserDataModule inu, Player src, String powertool, List<String> commands) {
Optional<ItemType> oit = Sponge.getRegistry().getType(ItemType.class, powertool);
MessageProvider mp = plugin.getMessageProvider();
// Create the click actions.
ClickAction viewAction = TextActions.executeCallback(pl -> Util.getPaginationBuilder(src).title(mp.getTextMessageWithFormat("command.powertool.ind.header", powertool)).padding(Text.of(TextColors.GREEN, "-")).contents(commands.stream().map(x -> Text.of(TextColors.YELLOW, x)).collect(Collectors.toList())).sendTo(src));
ClickAction deleteAction = TextActions.executeCallback(pl -> {
inu.clearPowertool(powertool);
pl.sendMessage(mp.getTextMessageWithFormat("command.powertool.removed", powertool));
});
TextColor tc = oit.map(itemType -> TextColors.YELLOW).orElse(TextColors.GRAY);
// id - [View] - [Delete]
return Text.builder().append(Text.of(tc, powertool)).append(Text.of(" - ")).append(Text.builder(mp.getMessageWithFormat("standard.view")).color(TextColors.YELLOW).onClick(viewAction).build()).append(Text.of(" - ")).append(Text.builder(mp.getMessageWithFormat("standard.delete")).color(TextColors.DARK_RED).onClick(deleteAction).build()).build();
}
Aggregations