diff options
author | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-08-25 19:58:07 +0800 |
---|---|---|
committer | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-08-25 19:58:07 +0800 |
commit | 68984c4463ff51d60e745d43bf51eb15540725d2 (patch) | |
tree | 48120c5cf481b341e8a192b6eef4ccddba022b6b /utils | |
parent | ee8f99633a66e12b1d0c6fb9daaedb2ba802b755 (diff) | |
download | SoopyV2-68984c4463ff51d60e745d43bf51eb15540725d2.tar.gz SoopyV2-68984c4463ff51d60e745d43bf51eb15540725d2.tar.bz2 SoopyV2-68984c4463ff51d60e745d43bf51eb15540725d2.zip |
+ fix dungeon map
+ powder hud fixes
+ guild bridge formatting
+ meta
Diffstat (limited to 'utils')
-rw-r--r-- | utils/utils.js | 17 |
1 files changed, 17 insertions, 0 deletions
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()) } } |