diff --git a/src/com/massivecraft/factions/Conf.java b/src/com/massivecraft/factions/Conf.java index e77895ae..b901810c 100644 --- a/src/com/massivecraft/factions/Conf.java +++ b/src/com/massivecraft/factions/Conf.java @@ -74,6 +74,7 @@ public class Conf public static boolean removePlayerDataWhenBanned = true; public static boolean worldGuardChecking = false; + public static boolean worldGuardBuildPriority = false; //LWC public static boolean lwcIntegration = false; diff --git a/src/com/massivecraft/factions/P.java b/src/com/massivecraft/factions/P.java index 4e72c621..9b06f68d 100644 --- a/src/com/massivecraft/factions/P.java +++ b/src/com/massivecraft/factions/P.java @@ -112,7 +112,7 @@ public class P extends MPlugin CapiFeatures.setup(); LWCFeatures.setup(); - if(Conf.worldGuardChecking) + if(Conf.worldGuardChecking || Conf.worldGuardBuildPriority) { Worldguard.init(this); } diff --git a/src/com/massivecraft/factions/integration/Worldguard.java b/src/com/massivecraft/factions/integration/Worldguard.java index 3bed62dd..8c05f188 100644 --- a/src/com/massivecraft/factions/integration/Worldguard.java +++ b/src/com/massivecraft/factions/integration/Worldguard.java @@ -75,7 +75,26 @@ public class Worldguard ApplicableRegionSet set = regionManager.getApplicableRegions(pt); return set.allows(DefaultFlag.PVP); } - + // Check if player can build at location by worldguards rules. + // Returns: + // True: Player can build in the region. + // False: Player can not build in the region. + public static boolean playerCanBuild(Player player, Location loc) + { + if( ! enabled) + { + // No WG hooks so we'll always bypass this check. + return false; + } + + World world = loc.getWorld(); + Vector pt = toVector(loc); + + if (wg.getRegionManager(world).getApplicableRegions(pt).size() > 0) + return wg.canBuild(player, loc); + return false; + } + // Check for Regions in chunk the chunk // Returns: // True: Regions found within chunk diff --git a/src/com/massivecraft/factions/listeners/FactionsBlockListener.java b/src/com/massivecraft/factions/listeners/FactionsBlockListener.java index def506ce..ddc535b7 100644 --- a/src/com/massivecraft/factions/listeners/FactionsBlockListener.java +++ b/src/com/massivecraft/factions/listeners/FactionsBlockListener.java @@ -20,6 +20,7 @@ import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.Faction; import com.massivecraft.factions.P; +import com.massivecraft.factions.integration.Worldguard; import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Relation; @@ -182,6 +183,12 @@ public class FactionsBlockListener implements Listener } else if (otherFaction.isSafeZone()) { + if (Conf.worldGuardBuildPriority) + { + if (Worldguard.playerCanBuild(player, location)) + return true; + } + if (!Conf.safeZoneDenyBuild || Permission.MANAGE_SAFE_ZONE.has(player)) return true;