Moved Essentials teleport integration handling to EssentialsFeatures.java
This commit is contained in:
parent
546ecd6a45
commit
50572b388c
@ -3,28 +3,23 @@ package com.massivecraft.factions.cmd;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
import com.earth2me.essentials.IEssentials;
|
|
||||||
import com.earth2me.essentials.Teleport;
|
|
||||||
import com.earth2me.essentials.Trade;
|
|
||||||
import com.massivecraft.factions.Board;
|
import com.massivecraft.factions.Board;
|
||||||
import com.massivecraft.factions.Conf;
|
import com.massivecraft.factions.Conf;
|
||||||
import com.massivecraft.factions.FLocation;
|
import com.massivecraft.factions.FLocation;
|
||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
import com.massivecraft.factions.FPlayers;
|
import com.massivecraft.factions.FPlayers;
|
||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
|
import com.massivecraft.factions.integration.EssentialsFeatures;
|
||||||
import com.massivecraft.factions.struct.FFlag;
|
import com.massivecraft.factions.struct.FFlag;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.struct.Rel;
|
import com.massivecraft.factions.struct.Rel;
|
||||||
import com.massivecraft.factions.zcore.util.SmokeUtil;
|
import com.massivecraft.factions.zcore.util.SmokeUtil;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public class CmdHome extends FCommand
|
public class CmdHome extends FCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -130,44 +125,24 @@ public class CmdHome extends FCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The teleport is either handled inhouse or by the Essentials plugin as a warp
|
// if Essentials teleport handling is enabled and available, pass the teleport off to it (for delay and cooldown)
|
||||||
final Plugin grab = Bukkit.getPluginManager().getPlugin("Essentials");
|
if (EssentialsFeatures.handleTeleport(me, myFaction.getHome())) return;
|
||||||
if (Conf.homesTeleportCommandEssentialsIntegration && grab != null && grab.isEnabled())
|
|
||||||
|
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||||
|
if ( ! payForCommand(Conf.econCostHome, "to teleport to your faction home", "for teleporting to your faction home")) return;
|
||||||
|
|
||||||
|
// Create a smoke effect
|
||||||
|
if (Conf.homesTeleportCommandSmokeEffectEnabled)
|
||||||
{
|
{
|
||||||
// Handled by Essentials
|
List<Location> smokeLocations = new ArrayList<Location>();
|
||||||
IEssentials ess = (IEssentials) grab;
|
smokeLocations.add(me.getLocation());
|
||||||
Teleport teleport = (Teleport) ess.getUser(this.me).getTeleport();
|
smokeLocations.add(me.getLocation().clone().add(0, 1, 0));
|
||||||
Trade trade = new Trade(Conf.econCostHome, ess);
|
smokeLocations.add(myFaction.getHome());
|
||||||
try
|
smokeLocations.add(myFaction.getHome().clone().add(0, 1, 0));
|
||||||
{
|
SmokeUtil.spawnCloudRandom(smokeLocations, 3f);
|
||||||
teleport.teleport(myFaction.getHome(), trade);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
me.sendMessage(ChatColor.RED.toString()+e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Handled by Factions
|
|
||||||
|
|
||||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
|
||||||
if ( ! payForCommand(Conf.econCostHome, "to teleport to your faction home", "for teleporting to your faction home")) return;
|
|
||||||
|
|
||||||
// Create a smoke effect
|
|
||||||
if (Conf.homesTeleportCommandSmokeEffectEnabled)
|
|
||||||
{
|
|
||||||
List<Location> smokeLocations = new ArrayList<Location>();
|
|
||||||
smokeLocations.add(me.getLocation());
|
|
||||||
smokeLocations.add(me.getLocation().clone().add(0, 1, 0));
|
|
||||||
smokeLocations.add(myFaction.getHome());
|
|
||||||
smokeLocations.add(myFaction.getHome().clone().add(0, 1, 0));
|
|
||||||
SmokeUtil.spawnCloudRandom(smokeLocations, 3f);
|
|
||||||
}
|
|
||||||
|
|
||||||
me.teleport(myFaction.getHome());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
me.teleport(myFaction.getHome());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,20 @@
|
|||||||
package com.massivecraft.factions.integration;
|
package com.massivecraft.factions.integration;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
import com.massivecraft.factions.Conf;
|
import com.massivecraft.factions.Conf;
|
||||||
import com.massivecraft.factions.P;
|
import com.massivecraft.factions.P;
|
||||||
|
|
||||||
|
import com.earth2me.essentials.IEssentials;
|
||||||
|
import com.earth2me.essentials.Teleport;
|
||||||
|
import com.earth2me.essentials.Trade;
|
||||||
import com.earth2me.essentials.chat.EssentialsChat;
|
import com.earth2me.essentials.chat.EssentialsChat;
|
||||||
import com.earth2me.essentials.chat.EssentialsLocalChatEvent;
|
import com.earth2me.essentials.chat.EssentialsLocalChatEvent;
|
||||||
|
|
||||||
@ -22,9 +27,21 @@ import com.earth2me.essentials.chat.EssentialsLocalChatEvent;
|
|||||||
public class EssentialsFeatures
|
public class EssentialsFeatures
|
||||||
{
|
{
|
||||||
private static EssentialsChat essChat;
|
private static EssentialsChat essChat;
|
||||||
|
private static IEssentials essentials;
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public static void setup()
|
public static void setup()
|
||||||
{
|
{
|
||||||
|
// integrate main essentials plugin
|
||||||
|
// TODO: this is the old Essentials method not supported in 3.0... probably needs to eventually be moved to EssentialsOldVersionFeatures and new method implemented
|
||||||
|
if (essentials == null)
|
||||||
|
{
|
||||||
|
Plugin ess = Bukkit.getPluginManager().getPlugin("Essentials");
|
||||||
|
if (ess != null && ess.isEnabled())
|
||||||
|
essentials = (IEssentials)ess;
|
||||||
|
}
|
||||||
|
|
||||||
|
// integrate chat
|
||||||
if (essChat != null) return;
|
if (essChat != null) return;
|
||||||
|
|
||||||
Plugin test = Bukkit.getServer().getPluginManager().getPlugin("EssentialsChat");
|
Plugin test = Bukkit.getServer().getPluginManager().getPlugin("EssentialsChat");
|
||||||
@ -61,6 +78,25 @@ public class EssentialsFeatures
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// return false if feature is disabled or Essentials isn't available
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void integrateChat(EssentialsChat instance)
|
public static void integrateChat(EssentialsChat instance)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user