From 024336d7170c796f4cc2d7e8b7ca4fcb3c381b21 Mon Sep 17 00:00:00 2001 From: drtshock Date: Mon, 19 May 2014 11:44:15 -0500 Subject: [PATCH] Readd essentials teleport cooldown hook. Fixes issue #5 --- pom.xml | 10 +++++ .../java/com/massivecraft/factions/P.java | 2 + .../factions/integration/Essentials.java | 37 +++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 src/main/java/com/massivecraft/factions/integration/Essentials.java diff --git a/pom.xml b/pom.xml index 75bddfba..04de2b7d 100644 --- a/pom.xml +++ b/pom.xml @@ -65,6 +65,12 @@ worldedit 5.6.1 + + net.ess3 + Essentials + 2.x-SNAPSHOT + provided + @@ -72,6 +78,10 @@ repo-daboross-net http://repo.daboross.net/ + + ess-repo + http://repo.ess3.net/content/groups/public + bukkit-repo http://repo.bukkit.org/content/groups/public/ diff --git a/src/main/java/com/massivecraft/factions/P.java b/src/main/java/com/massivecraft/factions/P.java index 004b92c5..f9333f02 100644 --- a/src/main/java/com/massivecraft/factions/P.java +++ b/src/main/java/com/massivecraft/factions/P.java @@ -3,6 +3,7 @@ package com.massivecraft.factions; import com.massivecraft.factions.cmd.CmdAutoHelp; import com.massivecraft.factions.cmd.FCmdRoot; import com.massivecraft.factions.integration.Econ; +import com.massivecraft.factions.integration.Essentials; import com.massivecraft.factions.integration.Worldguard; import com.massivecraft.factions.listeners.*; import com.massivecraft.factions.struct.ChatMode; @@ -86,6 +87,7 @@ public class P extends MPlugin { // Load Conf from disk Conf.load(); + Essentials.setup(); FPlayers.i.loadFromDisc(); Factions.i.loadFromDisc(); Board.load(); diff --git a/src/main/java/com/massivecraft/factions/integration/Essentials.java b/src/main/java/com/massivecraft/factions/integration/Essentials.java new file mode 100644 index 00000000..5de1eb52 --- /dev/null +++ b/src/main/java/com/massivecraft/factions/integration/Essentials.java @@ -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; + } +}