public static Text attachmentBuilder(List<Message.Attachment> attachments) { Text.Builder hover = Text.builder("Attachments: ") .append(Text.NEW_LINE); for (Message.Attachment attachment : attachments) { hover.append(Text.of(attachment.getFileName(), Text.NEW_LINE)); } hover.append(Text.of(TextColors.AQUA, "Click to open this attachment!")); URL url = null; try { url = new URL(attachments.get(0).getUrl()); } catch (MalformedURLException exception) {} return Text.builder() .append(ReplacerUtil.toText(MagiBridge.getConfig().MESSAGES.ATTACHMENT_NAME)) .onHover(TextActions.showText(hover.build())) .onClick(url != null ? TextActions.openUrl(url) : null) .build(); }