use of io.github.nucleuspowered.nucleus.internal.messages.MessageProvider in project Nucleus by NucleusPowered.
the class NucleusArgumentParseException method getUsage.
@Nullable
public Text getUsage() {
Text.Builder builder = Text.builder();
MessageProvider mp = Nucleus.getNucleus().getMessageProvider();
if (usage != null) {
builder.append(Text.NEW_LINE).append(mp.getTextMessageWithTextFormat("command.exception.usage", this.usage));
}
if (subcommands != null) {
builder.append(Text.NEW_LINE).append(mp.getTextMessageWithTextFormat("command.exception.subcommands", this.subcommands));
}
return builder.build();
}
use of io.github.nucleuspowered.nucleus.internal.messages.MessageProvider in project Nucleus by NucleusPowered.
the class NucleusCommandException method print.
private Text print(List<Tuple<String, CommandException>> lce) {
MessageProvider mp = Nucleus.getNucleus().getMessageProvider();
Text sept = mp.getTextMessageWithFormat("command.exception.separator");
Text.Builder builder = mp.getTextMessageWithFormat("command.exception.multiple").toBuilder();
lce.forEach(x -> builder.append(Text.NEW_LINE).append(sept).append(Text.NEW_LINE).append(mp.getTextMessageWithFormat("command.exception.fromcommand", x.getFirst())).append(Text.NEW_LINE).append(x.getSecond().getText()));
builder.append(Text.NEW_LINE).append(sept);
return builder.toText();
}
use of io.github.nucleuspowered.nucleus.internal.messages.MessageProvider in project Nucleus by NucleusPowered.
the class CoreListener method onPlayerJoinLast.
@Listener
public void onPlayerJoinLast(final ClientConnectionEvent.Join event, @Getter("getTargetEntity") final Player player) {
if (Nucleus.getNucleus().getUserDataManager().get(player).map(x -> x.get(CoreUserDataModule.class).isFirstPlay()).orElse(true)) {
NucleusFirstJoinEvent firstJoinEvent = new OnFirstLoginEvent(event.getCause(), player, event.getOriginalChannel(), event.getChannel().orElse(null), event.getOriginalMessage(), event.isMessageCancelled(), event.getFormatter());
Sponge.getEventManager().post(firstJoinEvent);
event.setChannel(firstJoinEvent.getChannel().get());
event.setMessageCancelled(firstJoinEvent.isMessageCancelled());
Nucleus.getNucleus().getUserDataManager().getUnchecked(player).get(CoreUserDataModule.class).setStartedFirstJoin(false);
}
// Warn about wildcard.
if (!ServiceChangeListener.isOpOnly() && player.hasPermission("nucleus")) {
MessageProvider provider = this.plugin.getMessageProvider();
Nucleus.getNucleus().getLogger().warn("The player " + player.getName() + " has got either the nucleus wildcard or the * wildcard " + "permission. This may cause unintended side effects.");
if (this.warnOnWildcard) {
// warn
List<Text> text = Lists.newArrayList();
text.add(provider.getTextMessageWithFormat("core.permission.wildcard2"));
text.add(provider.getTextMessageWithFormat("core.permission.wildcard3"));
if (this.url != null) {
text.add(provider.getTextMessageWithFormat("core.permission.wildcard4").toBuilder().onClick(TextActions.openUrl(this.url)).build());
}
text.add(provider.getTextMessageWithFormat("core.permission.wildcard5"));
Sponge.getServiceManager().provideUnchecked(PaginationService.class).builder().title(provider.getTextMessageWithFormat("core.permission.wildcard")).contents(text).padding(Text.of(TextColors.GOLD, "-")).sendTo(player);
}
}
}
use of io.github.nucleuspowered.nucleus.internal.messages.MessageProvider in project Nucleus by NucleusPowered.
the class NicknameCommand method afterPostInit.
@Override
protected void afterPostInit() {
super.afterPostInit();
MessageProvider mp = Nucleus.getNucleus().getMessageProvider();
String colPerm = permissions.getPermissionWithSuffix("colour.");
String colPerm2 = permissions.getPermissionWithSuffix("color.");
NameUtil.getColours().forEach((key, value) -> {
permissionToDesc.put(colPerm + value.getName(), mp.getMessageWithFormat("permission.nick.colourspec", value.getName().toLowerCase(), key.toString()));
permissionToDesc.put(colPerm2 + value.getName(), mp.getMessageWithFormat("permission.nick.colorspec", value.getName().toLowerCase(), key.toString()));
});
String stylePerm = permissions.getPermissionWithSuffix("style.");
NameUtil.getStyleKeys().entrySet().stream().filter(x -> x.getKey() != 'k').forEach((k) -> permissionToDesc.put(stylePerm + k.getValue().toLowerCase(), mp.getMessageWithFormat("permission.nick.stylespec", k.getValue().toLowerCase(), k.getKey().toString())));
}
use of io.github.nucleuspowered.nucleus.internal.messages.MessageProvider in project Nucleus by NucleusPowered.
the class NicknameService method register.
public void register() {
if (this.registered) {
return;
}
MessageProvider mp = Nucleus.getNucleus().getMessageProvider();
CommandPermissionHandler permissions = Nucleus.getNucleus().getPermissionRegistry().getPermissionsForNucleusCommand(NicknameCommand.class);
String colPerm = permissions.getPermissionWithSuffix("colour.");
String colPerm2 = permissions.getPermissionWithSuffix("color.");
NameUtil.getColours().forEach((key, value) -> replacements.put(new String[] { colPerm + value.getName(), colPerm2 + value.getName() }, Tuple.of(Pattern.compile("[&]+" + key.toString().toLowerCase(), Pattern.CASE_INSENSITIVE).matcher(""), mp.getTextMessageWithFormat("command.nick.colour.nopermswith", value.getName()))));
String stylePerm = permissions.getPermissionWithSuffix("style.");
NameUtil.getStyleKeys().entrySet().stream().filter(x -> x.getKey() != 'k').forEach((k) -> replacements.put(new String[] { stylePerm + k.getValue().toLowerCase() }, Tuple.of(Pattern.compile("[&]+" + k.getKey().toString().toLowerCase(), Pattern.CASE_INSENSITIVE).matcher(""), mp.getTextMessageWithFormat("command.nick.style.nopermswith", k.getValue().toLowerCase()))));
this.replacements.put(new String[] { permissions.getPermissionWithSuffix("magic") }, Tuple.of(Pattern.compile("[&]+k", Pattern.CASE_INSENSITIVE).matcher(""), mp.getTextMessageWithFormat("command.nick.style.nopermswith", "magic")));
this.registered = true;
}
Aggregations