Skip to content

Instantly share code, notes, and snippets.

@cindyker
Last active August 29, 2015 14:02
Show Gist options
  • Save cindyker/d735b882ca7f8e26de5b to your computer and use it in GitHub Desktop.
Save cindyker/d735b882ca7f8e26de5b to your computer and use it in GitHub Desktop.
String fancyLink = Utils.getFancyLink(line);
if(!fancyLink.isEmpty()) {
String tellRaw = "tellraw %player% {\"text\":\"\",\"extra\":[{\"text\":\"%before%\",\"color\":\"white\"},{\"text\":\"%site%\",\"color\":\"white\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"%link%\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"" + ChatColor.YELLOW + Utils.transcribeColorCodes(plugin.FANCY_LINK_POPUP) +"\"}},{\"text\":\"%after%\",\"color\":\"white\"}]}";
line = line.replace(fancyLink, "%split%");
String[] beforeAndAfter = line.split("%split%");
if(beforeAndAfter.length != 0) {
int count = 1;
for(String s : beforeAndAfter) {
if(count == 1) {
tellRaw = tellRaw.replace("%before%", s); }
else if(count == 2) {
tellRaw = tellRaw.replace("%after%", s); }
count++;
}
}
tellRaw = tellRaw.replace("%before%", "").replace("%after%", "");
String[] linkData = fancyLink.replace("{", "").replace("}", "").split(">");
if(linkData.length > 0) {
tellRaw = tellRaw.replace("%site%", linkData[0].trim()).replace("%link%", linkData[1].trim());
}
tellRaw = tellRaw.replace("%player%", sender.getName());
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), tellRaw);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment