From 68984c4463ff51d60e745d43bf51eb15540725d2 Mon Sep 17 00:00:00 2001 From: Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> Date: Thu, 25 Aug 2022 19:58:07 +0800 Subject: + fix dungeon map + powder hud fixes + guild bridge formatting + meta --- utils/utils.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'utils') diff --git a/utils/utils.js b/utils/utils.js index 15b5489..0e916ae 100644 --- a/utils/utils.js +++ b/utils/utils.js @@ -118,6 +118,23 @@ let utils = { var result = []; p(array, []); return result; + }, + toMessageWithLinks: function (text, color = "f") { + return text.split(" ").reduce((c, curr) => { + if (curr.match(/(?:(?:https?|ftp|file):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$])/igm)) { + c.push(curr) + c.push("&" + color) + } else { + c[c.length - 1] += (c[c.length - 1].length === 2 ? "" : " ") + curr + } + return c + }, ["&" + color]).map(a => { + if (a.match(/(?:(?:https?|ftp|file):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$])/igm)) { + return new TextComponent("&" + color + "&n" + a + "&" + color + ' ').setHover("show_text", "Click to open " + a.trim()).setClick("open_url", a.trim()) + } else { + return new TextComponent(a + ' ') + } + }).reduce((c, curr) => c.addTextComponent(curr), new Message()) } } -- cgit