2014-05-19 18:44:15 +02:00
|
|
|
package com.massivecraft.factions.integration;
|
|
|
|
|
|
|
|
import com.earth2me.essentials.IEssentials;
|
|
|
|
import com.earth2me.essentials.Teleport;
|
|
|
|
import com.earth2me.essentials.Trade;
|
|
|
|
import com.massivecraft.factions.Conf;
|
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.Location;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.plugin.Plugin;
|
|
|
|
|
|
|
|
public class Essentials {
|
|
|
|
|
|
|
|
private static IEssentials essentials;
|
|
|
|
|
|
|
|
public static void setup() {
|
2014-07-01 22:10:18 +02:00
|
|
|
Plugin ess = Bukkit.getPluginManager().getPlugin("Essentials");
|
|
|
|
if (ess != null) {
|
2014-05-19 18:44:15 +02:00
|
|
|
essentials = (IEssentials) ess;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// return false if feature is disabled or Essentials isn't available
|
|
|
|
public static boolean handleTeleport(Player player, Location loc) {
|
2014-07-01 22:10:18 +02:00
|
|
|
if (!Conf.homesTeleportCommandEssentialsIntegration || essentials == null) {
|
|
|
|
return false;
|
|
|
|
}
|
2014-05-19 18:44:15 +02:00
|
|
|
|
2014-07-08 20:54:22 +02:00
|
|
|
Teleport teleport = essentials.getUser(player).getTeleport();
|
2014-07-01 22:10:18 +02:00
|
|
|
Trade trade = new Trade(Conf.econCostHome, essentials);
|
|
|
|
try {
|
2014-05-19 18:44:15 +02:00
|
|
|
teleport.teleport(loc, trade);
|
|
|
|
} catch (Exception e) {
|
|
|
|
player.sendMessage(ChatColor.RED.toString() + e.getMessage());
|
2014-07-01 22:10:18 +02:00
|
|
|
}
|
|
|
|
return true;
|
2014-05-19 18:44:15 +02:00
|
|
|
}
|
2014-11-07 19:08:57 +01:00
|
|
|
|
|
|
|
public static boolean isVanished(Player player) {
|
2014-12-07 21:26:13 +01:00
|
|
|
if (essentials == null) {
|
2014-11-07 19:38:45 +01:00
|
|
|
return false;
|
|
|
|
}
|
2014-11-07 19:08:57 +01:00
|
|
|
return essentials.getUser(player).isVanished();
|
|
|
|
}
|
2014-05-19 18:44:15 +02:00
|
|
|
}
|