package net.simpvp.ignore;

import java.util.Arrays;
import java.util.HashMap;
import java.util.UUID;

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

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

/**
 * Implements the /r and /m commands
 */
public class PMCommands implements CommandExecutor {

	/* (both hashmaps) Key is the sender, value is their recipient
	 * I.e. if (A, B) is in mPlayerList, then the next time A
	 * does /m it will be sent to B, and similar for rPlayerList */
	public static HashMap<UUID, UUID> mPlayerList
		= new HashMap<UUID, UUID>();
	public static HashMap<UUID, UUID> rPlayerList
		= new HashMap<UUID, UUID>();

	public boolean onCommand(
			CommandSender sender,
			Command cmd,
			String label,
			String[] args) {

		Player player = null;
		UUID uplayer = null;
		if (sender instanceof Player) {
			player = (Player) sender;
			uplayer = player.getUniqueId();
		}

		if (args.length < 1) {
			TextComponent m = new TextComponent("You cannot send an empty message.");
			m.setColor(ChatColor.RED);
			Chat.send_chat(player, m);

			return true;
		}

		String[] msg = Arrays.copyOfRange(args, 1, args.length);

		UUID utarget;
		if (cmd.getName().equalsIgnoreCase("m")) {
			if (!mPlayerList.containsKey(uplayer)) {
				TextComponent m = new TextComponent("You have not sent any PMs yet.");
				m.setColor(ChatColor.RED);
				Chat.send_chat(player, m);
				return true;
			}
			utarget = mPlayerList.get(uplayer);
		} else {
			if (!rPlayerList.containsKey(uplayer)) {
				TextComponent m = new TextComponent("You have not received any PMs yet.");
				m.setColor(ChatColor.RED);
				Chat.send_chat(player, m);
				return true;
			}
			utarget = rPlayerList.get(uplayer);
		}

		Player target = null;
		if (utarget != null) {
			target = Ignore.instance.getServer().getPlayer(utarget);
		}

		TellCommand.sendPM(player, target, msg, utarget == null);

		return true;
	}

}


@@ -1223,68 +1223,8 @@
 %09%7D%0A%0A
-%09%09String%5B%5D msg = Arrays.copyOfRange(args, 1, args.length);%0A%0A
 %09%09UU
@@ -1939,11 +1939,12 @@
 et, 
-msg
+args
 , ut

Fix bug in /m and /r where it cut off first arg