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

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

import org.bukkit.entity.Player;

import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.User;

public class EssentialsInterface {

	public static Essentials getPlugin() {
		try {
		return (Essentials) PandacraftUtils.getInstance().getServer().getPluginManager().getPlugin("Essentials");
		} catch (Exception e) { return null; }
	}
	
	
	public static User getPlayer(Player p) {
		try {
			return getPlugin().getUser(p);
		} catch (Exception e) { }
		return null;
	}
	
	public static boolean isPlayerVanished(Player p) {
		try {
			return getPlayer(p).isVanished();
		} catch (Exception e) { }
		return false;
	}

	public static boolean canPlayerSeeVanishedPlayer(Player p, Player hiddenP) {
		try {
			return getPlugin().getUser(p).canSee(hiddenP);
		} catch (Exception e) { }
		return true;
	}
	
	public static boolean isPlayerMuted(Player p) {
		try {
			return getPlugin().getUser(p).isMuted();
		} catch (Exception e) { }
		return false;
	}
	

	public static double getPlayerMoney(Player p) {
		try {
			return getPlugin().getUser(p).getMoney().doubleValue();
		} catch (Exception e) { }
		return Double.NaN;
	}
}
