Add Faction warps
This commit is contained in:
@@ -12,8 +12,9 @@ import com.massivecraft.factions.event.EventFactionsCreate;
|
||||
import com.massivecraft.factions.event.EventFactionsDescriptionChange;
|
||||
import com.massivecraft.factions.event.EventFactionsDisband;
|
||||
import com.massivecraft.factions.event.EventFactionsFlagChange;
|
||||
import com.massivecraft.factions.event.EventFactionsHomeChange;
|
||||
import com.massivecraft.factions.event.EventFactionsHomeTeleport;
|
||||
import com.massivecraft.factions.event.EventFactionsWarpAdd;
|
||||
import com.massivecraft.factions.event.EventFactionsWarpRemove;
|
||||
import com.massivecraft.factions.event.EventFactionsWarpTeleport;
|
||||
import com.massivecraft.factions.event.EventFactionsInvitedChange;
|
||||
import com.massivecraft.factions.event.EventFactionsMembershipChange;
|
||||
import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason;
|
||||
@@ -177,13 +178,22 @@ public class EngineEcon extends Engine
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void payForCommand(EventFactionsHomeChange event)
|
||||
public void payForCommand(EventFactionsWarpAdd event)
|
||||
{
|
||||
Double cost = MConf.get().econCostSethome;
|
||||
String desc = CmdFactions.get().cmdFactionsSethome.getDesc();
|
||||
Double cost = MConf.get().econCostWarpAdd;
|
||||
String desc = CmdFactions.get().cmdFactionsWarp.cmdFactionWarpAdd.getDesc();
|
||||
|
||||
payForAction(event, cost, desc);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void payForCommand(EventFactionsWarpRemove event)
|
||||
{
|
||||
Double cost = MConf.get().econCostWarpRemove;
|
||||
String desc = CmdFactions.get().cmdFactionsWarp.cmdFactionWarpRemove.getDesc();
|
||||
|
||||
payForAction(event, cost, desc);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void payForCommand(EventFactionsCreate event)
|
||||
@@ -240,13 +250,12 @@ public class EngineEcon extends Engine
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void payForCommand(EventFactionsHomeTeleport event)
|
||||
public void payForCommand(EventFactionsWarpTeleport event)
|
||||
{
|
||||
Double cost = MConf.get().econCostHome;
|
||||
String desc = CmdFactions.get().cmdFactionsHome.getDesc();
|
||||
Double cost = MConf.get().econCostWarpGo;
|
||||
String desc = CmdFactions.get().cmdFactionsWarp.cmdFactionsWarpGo.getDesc();
|
||||
|
||||
payForAction(event, cost, desc);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ package com.massivecraft.factions.engine;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.entity.MConf;
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
import com.massivecraft.factions.entity.Warp;
|
||||
import com.massivecraft.massivecore.Engine;
|
||||
import com.massivecraft.massivecore.ps.PS;
|
||||
import com.massivecraft.massivecore.util.MUtil;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -12,6 +12,8 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class EngineTeleportHomeOnDeath extends Engine
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
@@ -33,23 +35,25 @@ public class EngineTeleportHomeOnDeath extends Engine
|
||||
final MPlayer mplayer = MPlayer.get(player);
|
||||
|
||||
// ... homes are enabled, active and at this priority ...
|
||||
if (!MConf.get().homesEnabled) return;
|
||||
if (!MConf.get().homesTeleportToOnDeathActive) return;
|
||||
if (MConf.get().homesTeleportToOnDeathPriority != priority) return;
|
||||
if (!MConf.get().warpsEnabled) return;
|
||||
if (!MConf.get().warpsTeleportToOnDeathActive) return;
|
||||
if (MConf.get().warpsTeleportToOnDeathPriority != priority) return;
|
||||
|
||||
// ... and the player has a faction ...
|
||||
final Faction faction = mplayer.getFaction();
|
||||
if (faction.isNone()) return;
|
||||
|
||||
// ... and the faction has a home ...
|
||||
PS home = faction.getHome();
|
||||
if (home == null) return;
|
||||
List<Warp> warps = faction.getWarps().getAll(warp -> warp.getName().equalsIgnoreCase(MConf.get().warpsTeleportToOnDeathName));
|
||||
if (warps.isEmpty()) return;
|
||||
|
||||
Warp warp = warps.get(0);
|
||||
|
||||
// ... and the home is translatable ...
|
||||
Location respawnLocation = null;
|
||||
try
|
||||
{
|
||||
respawnLocation = home.asBukkitLocation(true);
|
||||
respawnLocation = warp.getLocation().asBukkitLocation(true);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user