package net.mc_pandacraft.java.plugin.pandacraftutils.network_api.request_executors;

import net.mc_pandacraft.java.plugin.pandacraftutils.network_api.Response;

public class RequestExecutorCommandAsync extends AbstractRequestExecutor {

	public RequestExecutorCommandAsync() {
		super("command_async");
	}
	
	@Override
	protected Response run(String data) {
		Response rep = new Response();
		
		try
		{
			rep.good = plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), data);
			 
			if (!rep.good)
			{
				plugin.getLogger().warning("La commande ne peut pas s'exécuter : /"+data);
				rep.data = "command sent but CommandExecutor has not return success";
			}
		}
		catch (Exception e)
		{
			plugin.getLogger().severe(e.getMessage());
			rep.good = false;
			rep.data = "Exception : "+e.getMessage();
		}
		
		
		return rep;
	}

}
