Readd essentials teleport cooldown hook. Fixes issue #5

This commit is contained in:
drtshock
2014-05-19 11:44:15 -05:00
parent 7107829446
commit 024336d717
3 changed files with 49 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
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() {
Plugin ess = Bukkit.getPluginManager().getPlugin("Essentials");
if(ess != null) {
essentials = (IEssentials) ess;
}
}
// return false if feature is disabled or Essentials isn't available
public static boolean handleTeleport(Player player, Location loc) {
if (!Conf.homesTeleportCommandEssentialsIntegration || essentials == null) return false;
Teleport teleport = (Teleport) essentials.getUser(player).getTeleport();
Trade trade = new Trade(Conf.econCostHome, essentials);
try {
teleport.teleport(loc, trade);
} catch (Exception e) {
player.sendMessage(ChatColor.RED.toString() + e.getMessage());
}
return true;
}
}