diff --git a/src/com/massivecraft/factions/ConfServer.java b/src/com/massivecraft/factions/ConfServer.java index 59c5fe4d..563b211a 100644 --- a/src/com/massivecraft/factions/ConfServer.java +++ b/src/com/massivecraft/factions/ConfServer.java @@ -30,17 +30,7 @@ public class ConfServer extends SimpleConfig public static double autoLeaveRoutineRunsEveryXMinutes = 5.0; public static boolean removePlayerDataWhenBanned = true; - // -------------------------------------------- // - // HOMES - // -------------------------------------------- // - - public static boolean homesEnabled = true; - public static boolean homesMustBeInClaimedTerritory = true; - public static boolean homesTeleportCommandEnabled = true; - public static boolean homesTeleportAllowedFromEnemyTerritory = true; - public static boolean homesTeleportAllowedFromDifferentWorld = true; - public static double homesTeleportAllowedEnemyDistance = 32.0; - public static boolean homesTeleportIgnoreEnemiesIfInOwnTerritory = true; + // -------------------------------------------- // // PVP diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsHome.java b/src/com/massivecraft/factions/cmd/CmdFactionsHome.java index fbd3db62..b1b032f7 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsHome.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsHome.java @@ -4,13 +4,13 @@ import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Player; -import com.massivecraft.factions.ConfServer; import com.massivecraft.factions.FFlag; import com.massivecraft.factions.Factions; import com.massivecraft.factions.Perm; import com.massivecraft.factions.Rel; import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast; import com.massivecraft.factions.entity.BoardColls; +import com.massivecraft.factions.entity.UConf; import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.event.FactionsEventHomeTeleport; @@ -35,14 +35,16 @@ public class CmdFactionsHome extends FCommand @Override public void perform() { + UConf uconf = UConf.get(sender); + // TODO: Hide this command on help also. - if ( ! ConfServer.homesEnabled) + if ( ! uconf.homesEnabled) { fme.msg("Sorry, Faction homes are disabled on this server."); return; } - if ( ! ConfServer.homesTeleportCommandEnabled) + if ( ! uconf.homesTeleportCommandEnabled) { fme.msg("Sorry, the ability to teleport to Faction homes is disabled on this server."); return; @@ -55,13 +57,13 @@ public class CmdFactionsHome extends FCommand return; } - if ( ! ConfServer.homesTeleportAllowedFromEnemyTerritory && fme.isInEnemyTerritory()) + if ( ! uconf.homesTeleportAllowedFromEnemyTerritory && fme.isInEnemyTerritory()) { fme.msg("You cannot teleport to your faction home while in the territory of an enemy faction."); return; } - if (!ConfServer.homesTeleportAllowedFromDifferentWorld && !me.getWorld().getName().equalsIgnoreCase(myFaction.getHome().getWorld())) + if (!uconf.homesTeleportAllowedFromDifferentWorld && !me.getWorld().getName().equalsIgnoreCase(myFaction.getHome().getWorld())) { fme.msg("You cannot teleport to your faction home while in a different world."); return; @@ -74,7 +76,7 @@ public class CmdFactionsHome extends FCommand // if player is not in a safe zone or their own faction territory, only allow teleport if no enemies are nearby if ( - ConfServer.homesTeleportAllowedEnemyDistance > 0 + uconf.homesTeleportAllowedEnemyDistance > 0 && faction.getFlag(FFlag.PVP) && @@ -84,7 +86,7 @@ public class CmdFactionsHome extends FCommand ( fme.isInOwnTerritory() && - ! ConfServer.homesTeleportIgnoreEnemiesIfInOwnTerritory + ! uconf.homesTeleportIgnoreEnemiesIfInOwnTerritory ) ) ) @@ -107,13 +109,13 @@ public class CmdFactionsHome extends FCommand double dx = Math.abs(x - l.getX()); double dy = Math.abs(y - l.getY()); double dz = Math.abs(z - l.getZ()); - double max = ConfServer.homesTeleportAllowedEnemyDistance; + double max = uconf.homesTeleportAllowedEnemyDistance; // box-shaped distance check if (dx > max || dy > max || dz > max) continue; - fme.msg("You cannot teleport to your faction home while an enemy is within " + ConfServer.homesTeleportAllowedEnemyDistance + " blocks of you."); + fme.msg("You cannot teleport to your faction home while an enemy is within " + uconf.homesTeleportAllowedEnemyDistance + " blocks of you."); return; } } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsSethome.java b/src/com/massivecraft/factions/cmd/CmdFactionsSethome.java index a70272d8..6d6dde07 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsSethome.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsSethome.java @@ -1,11 +1,11 @@ package com.massivecraft.factions.cmd; -import com.massivecraft.factions.ConfServer; import com.massivecraft.factions.FPerm; import com.massivecraft.factions.Factions; import com.massivecraft.factions.Perm; import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.entity.Faction; +import com.massivecraft.factions.entity.UConf; import com.massivecraft.factions.event.FactionsEventHomeChange; import com.massivecraft.mcore.cmd.req.ReqHasPerm; import com.massivecraft.mcore.cmd.req.ReqIsPlayer; @@ -26,19 +26,19 @@ public class CmdFactionsSethome extends FCommand @Override public void perform() { - // TODO: Make a command REQ instead? - if ( ! ConfServer.homesEnabled) - { - fme.msg("Sorry, Faction homes are disabled on this server."); - return; - } - // Args Faction faction = this.arg(0, ARFaction.get(myFaction), myFaction); if (faction == null) return; PS newHome = PS.valueOf(me.getLocation()); + // Validate + if ( ! UConf.get(faction).homesEnabled) + { + fme.msg("Sorry, Faction homes are disabled on this server."); + return; + } + // FPerm if ( ! FPerm.SETHOME.has(sender, faction, true)) return; diff --git a/src/com/massivecraft/factions/entity/Faction.java b/src/com/massivecraft/factions/entity/Faction.java index 93c495f9..1fe35b12 100644 --- a/src/com/massivecraft/factions/entity/Faction.java +++ b/src/com/massivecraft/factions/entity/Faction.java @@ -231,7 +231,7 @@ public class Faction extends Entity implements EconomyParticipator public boolean isValidHome(PS ps) { if (ps == null) return true; - if (!ConfServer.homesMustBeInClaimedTerritory) return true; + if (!UConf.get(this).homesMustBeInClaimedTerritory) return true; if (BoardColls.get().getFactionAt(ps) == this) return true; return false; } diff --git a/src/com/massivecraft/factions/entity/UConf.java b/src/com/massivecraft/factions/entity/UConf.java index 54aa6495..89db3281 100644 --- a/src/com/massivecraft/factions/entity/UConf.java +++ b/src/com/massivecraft/factions/entity/UConf.java @@ -60,6 +60,18 @@ public class UConf extends Entity public double powerPerHour = 2.0; public double powerPerDeath = -2.0; + // -------------------------------------------- // + // HOMES + // -------------------------------------------- // + + public boolean homesEnabled = true; + public boolean homesMustBeInClaimedTerritory = true; + public boolean homesTeleportCommandEnabled = true; + public boolean homesTeleportAllowedFromEnemyTerritory = true; + public boolean homesTeleportAllowedFromDifferentWorld = true; + public double homesTeleportAllowedEnemyDistance = 32.0; + public boolean homesTeleportIgnoreEnemiesIfInOwnTerritory = true; + // -------------------------------------------- // // DENY COMMANDS // -------------------------------------------- //