package net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface;

import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;

import org.bukkit.entity.Player;

import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
import com.sk89q.worldedit.bukkit.selections.Selection;

public class WorldEditInterface {

	public static WorldEditPlugin getPlugin() {
		try {
		return (WorldEditPlugin) PandacraftUtils.getInstance().getServer().getPluginManager().getPlugin("WorldEdit");
		} catch (Exception e) { return null; }
	}
	

	
	public static CuboidSelection getPlayerCuboSelection(Player p) {
		WorldEditPlugin wePlugin = getPlugin();
		if (wePlugin == null) return null;
		Selection sel = wePlugin.getSelection(p);
		if (sel == null) return null;
		// on garde que les cuboïdes (pas les autres formes)
		if (!(sel instanceof CuboidSelection))
			return null;
		return (CuboidSelection) sel;
		
	}
	
}
