use of io.github.nucleuspowered.nucleus.NameUtil in project Nucleus by NucleusPowered.
the class ChatListener method useMessage.
private Text useMessage(Player player, Text rawMessage, ChatTemplateConfig chatTemplateConfig) {
String m = stripPermissionless(player, TextSerializers.FORMATTING_CODE.serialize(rawMessage));
if (chatConfig.isRemoveBlueUnderline()) {
m = m.replaceAll("&9&n([A-Za-z0-9-.]+)", "$1");
}
Text result;
if (player.hasPermission(prefix + "url")) {
result = TextParsingUtils.addUrls(m);
} else {
result = TextSerializers.FORMATTING_CODE.deserialize(m);
}
String chatcol = Util.getOptionFromSubject(player, "chatcolour", "chatcolor").orElseGet(chatTemplateConfig::getChatcolour);
String chatstyle = Util.getOptionFromSubject(player, "chatstyle").orElseGet(chatTemplateConfig::getChatstyle);
NameUtil nu = plugin.getNameUtil();
return Text.of(nu.getColourFromString(chatcol), nu.getTextStyleFromString(chatstyle), result);
}
use of io.github.nucleuspowered.nucleus.NameUtil in project Nucleus by NucleusPowered.
the class GetFromIpCommand method executeCommand.
@Override
protected CommandResult executeCommand(CommandSource src, CommandContext args) throws Exception {
String ip = args.<String>getOne(ipKey).get();
if (Arrays.stream(ip.split("\\.")).anyMatch(x -> Integer.parseInt(x) > 255)) {
throw ReturnMessageException.fromKey("command.getfromip.notvalid");
}
UserStorageService uss = Sponge.getServiceManager().provideUnchecked(UserStorageService.class);
List<User> users = plugin.getUserCacheService().getForIp(ip).stream().map(uss::get).filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList());
if (users.isEmpty()) {
src.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("command.getfromip.nousers"));
return CommandResult.success();
}
NameUtil name = plugin.getNameUtil();
Util.getPaginationBuilder(src).title(plugin.getMessageProvider().getTextMessageWithFormat("command.getfromip.title", ip)).contents(users.stream().map(y -> {
Text n = name.getName(y);
return n.toBuilder().onClick(TextActions.runCommand("/nucleus:seen " + y.getName())).onHover(TextActions.showText(plugin.getMessageProvider().getTextMessageWithTextFormat("command.getfromip.hover", n))).build();
}).collect(Collectors.toList())).sendTo(src);
return CommandResult.success();
}
Aggregations