Added API method for checking if URL's should be underlined in chat

This commit is contained in:
Aust1n46 2020-05-04 22:31:22 -04:00
parent 2ceb87f28e
commit 57c791e997

View File

@ -143,7 +143,7 @@ public class Format {
String https = ""; String https = "";
if(ChatColor.stripColor(link).contains("https://")) if(ChatColor.stripColor(link).contains("https://"))
https = "s"; 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); lastCode = getLastCode(lastCode + link);
remaining = remaining.substring(indexLinkEnd); remaining = remaining.substring(indexLinkEnd);
} }
@ -478,4 +478,8 @@ public class Format {
public static String escapeAllRegex(String input) { public static String escapeAllRegex(String input) {
return input.replace("[", "\\[").replace("]", "\\]").replace("{", "\\{").replace("}", "\\}").replace("(", "\\(").replace(")", "\\)").replace("|", "\\|").replace("+", "\\+").replace("*", "\\*"); return input.replace("[", "\\[").replace("]", "\\]").replace("{", "\\{").replace("}", "\\}").replace("(", "\\(").replace(")", "\\)").replace("|", "\\|").replace("+", "\\+").replace("*", "\\*");
} }
public static boolean underlineURLs() {
return plugin.getConfig().getBoolean("underlineurls", true);
}
} }