package me.ci.Commands;

import java.util.Set;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import me.ci.HavenGames;
import me.ci.BuilderTasks.GenerateMountainTask;

public class GenerateMountainCommand implements CommandExecutor{
	@Override
	public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
		if(!(sender instanceof Player)){
			sender.sendMessage(ChatColor.RED+"You must be a player to preform this command!");
			return true;
		}
		if(!sender.isOp()){
			sender.sendMessage(ChatColor.RED+"You do not have permission to preform this command!");
			return true;
		}
		if(args.length!=0){
			sender.sendMessage(ChatColor.RED+"Incorrect number of parameters! Please use as:");
			sender.sendMessage(ChatColor.GOLD+"/GenerateMountain");
			return true;
		}
		Block block = ((Player)sender).getTargetBlock((Set<Material>)null, 50);
		if(block==null||block.getType()==Material.AIR){
			sender.sendMessage(ChatColor.RED+"You must be looking at the area which you wish to place the mountain, at!");
			return true;
		}
		HavenGames.Instance.getBuilder().addTask(new GenerateMountainTask(block.getWorld(), block.getX(), block.getY(), block.getZ()));
		sender.sendMessage(ChatColor.GREEN+"Generating mountain now.");
		return true;
	}
}
