package net.simpvp.ignore;

import org.bukkit.entity.Player;

import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.TextComponent;

/**
 * Various functions for dealing with Minecraft Chat / TextComponent.
 */
public class Chat {

	/**
	 * Common function for sending a message to somebody
	 */
	public static void send_chat(
			Player player,
			TextComponent msg) {
		if (player == null) {
			Ignore.instance.getLogger().info(msg.getText());
		} else {
			player.spigot().sendMessage(msg);
		}
	}

	public static void receive_pm(Player player, Player sender, String message) {
		String s;
		if (sender == null) {
			s = "Server";
		} else {
			s = sender.getName();
		}

		TextComponent m = new TextComponent(String.format("<--%s: %s", s, message));
		m.setColor(ChatColor.GRAY);

		send_chat(player, m);
		LastLog.add_to_log(player, m);
	}

	public static void send_pm(Player player, Player target, String message) {
		String s;
		if (target == null) {
			s = "Server";
		} else {
			s = target.getName();
		}

		TextComponent m = new TextComponent(String.format("-->%s: %s", s, message));
		m.setColor(ChatColor.GRAY);

		send_chat(player, m);
	}

	public static void server_receive_pm(Player player, String message) {
		TextComponent m = new TextComponent(String.format("Server<--%s: %s", player.getName(), message));
		m.setColor(ChatColor.DARK_GRAY);

		send_chat(null, m);
		for (Player p : Ignore.instance.getServer().getOnlinePlayers()) {
			if (p.isOp() == false) {
				continue;
			}

			send_chat(p, m);
			LastLog.add_to_log(p, m);
		}
	}

	public static void server_send_pm(Player player, String message) {
		TextComponent m = new TextComponent(String.format("Server-->%s: %s", player.getName(), message));
		m.setColor(ChatColor.DARK_GRAY);

		send_chat(null, m);
		for (Player p: Ignore.instance.getServer().getOnlinePlayers()) {
			if (p.isOp() == false) {
				continue;
			}

			send_chat(p, m);
		}
	}
}

@@ -93,16 +93,60 @@
 tColor;%0A
+import net.md_5.bungee.api.chat.ClickEvent;%0A
 import n
@@ -184,16 +184,16 @@
 ponent;%0A
-
 %0A/**%0A * 
@@ -826,32 +826,133 @@
 ChatColor.GRAY);
+%0A%09%09m.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, String.format(%22/tell %25s %22, s)));
 %0A%0A%09%09send_chat(pl
@@ -1272,24 +1272,125 @@
 Color.GRAY);
+%0A%09%09m.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, String.format(%22/tell %25s %22, s)));
 %0A%0A%09%09send_cha
@@ -1604,32 +1604,154 @@
 olor.DARK_GRAY);
+%0A%09%09m.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, String.format(%22/servertell %25s %22, player.getName())));
 %0A%0A%09%09send_chat(nu
@@ -2091,32 +2091,32 @@
 e(), message));%0A
-
 %09%09m.setColor(Cha
@@ -2133,16 +2133,138 @@
 K_GRAY);
+%0A%09%09m.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, String.format(%22/servertell %25s %22, player.getName())));
 %0A%0A%09%09send

Add click action to PMs