From 57c791e997cef56a879dfce7a92fce0beae22bbb Mon Sep 17 00:00:00 2001 From: Aust1n46 Date: Mon, 4 May 2020 22:31:22 -0400 Subject: [PATCH] Added API method for checking if URL's should be underlined in chat --- MineverseChat/mineverse/Aust1n46/chat/utilities/Format.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/MineverseChat/mineverse/Aust1n46/chat/utilities/Format.java b/MineverseChat/mineverse/Aust1n46/chat/utilities/Format.java index e9ef53a..e3f21fa 100644 --- a/MineverseChat/mineverse/Aust1n46/chat/utilities/Format.java +++ b/MineverseChat/mineverse/Aust1n46/chat/utilities/Format.java @@ -143,7 +143,7 @@ public class Format { String https = ""; if(ChatColor.stripColor(link).contains("https://")) https = "s"; - temp += convertToJsonColors(lastCode + link, ",\"underlined\":\"" + plugin.getConfig().getBoolean("underlineurls", true) + "\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"http" + https + "://" + ChatColor.stripColor(link.replace("http://", "").replace("https://", "")) + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[" + convertToJsonColors(lastCode + link) + "]}}") + ","; + temp += convertToJsonColors(lastCode + link, ",\"underlined\":\"" + underlineURLs() + "\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"http" + https + "://" + ChatColor.stripColor(link.replace("http://", "").replace("https://", "")) + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[" + convertToJsonColors(lastCode + link) + "]}}") + ","; lastCode = getLastCode(lastCode + link); remaining = remaining.substring(indexLinkEnd); } @@ -478,4 +478,8 @@ public class Format { public static String escapeAllRegex(String input) { return input.replace("[", "\\[").replace("]", "\\]").replace("{", "\\{").replace("}", "\\}").replace("(", "\\(").replace(")", "\\)").replace("|", "\\|").replace("+", "\\+").replace("*", "\\*"); } + + public static boolean underlineURLs() { + return plugin.getConfig().getBoolean("underlineurls", true); + } } \ No newline at end of file