From 774d013cd0b6c5008f15d8a01f6deb4cf7b68e0c Mon Sep 17 00:00:00 2001 From: flatbmx Date: Sat, 8 Sep 2012 11:02:36 -0500 Subject: [PATCH 1/2] Added WorldGuard region building overriding safezone build rules if enabled. --- src/com/massivecraft/factions/Conf.java | 1 + src/com/massivecraft/factions/P.java | 2 +- .../factions/integration/Worldguard.java | 12 +++++++++++- .../factions/listeners/FactionsBlockListener.java | 7 +++++++ 4 files changed, 20 insertions(+), 2 deletions(-) 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..e5807db8 100644 --- a/src/com/massivecraft/factions/integration/Worldguard.java +++ b/src/com/massivecraft/factions/integration/Worldguard.java @@ -75,7 +75,17 @@ public class Worldguard ApplicableRegionSet set = regionManager.getApplicableRegions(pt); return set.allows(DefaultFlag.PVP); } - + + public static boolean playerCanBuild(Player player, Location loc) + { + if( ! enabled) + { + // No WG hooks so we'll always bypass this check. + return false; + } + return wg.canBuild(player, loc); + } + // 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; From 909f605343b8332333cbbb224aa00b4baa79ec9d Mon Sep 17 00:00:00 2001 From: flatbmx Date: Sat, 8 Sep 2012 11:22:18 -0500 Subject: [PATCH 2/2] fixed default build if there was no region at location. --- .../factions/integration/Worldguard.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/com/massivecraft/factions/integration/Worldguard.java b/src/com/massivecraft/factions/integration/Worldguard.java index e5807db8..8c05f188 100644 --- a/src/com/massivecraft/factions/integration/Worldguard.java +++ b/src/com/massivecraft/factions/integration/Worldguard.java @@ -75,7 +75,10 @@ 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) @@ -83,7 +86,13 @@ public class Worldguard // No WG hooks so we'll always bypass this check. return false; } - return wg.canBuild(player, loc); + + 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