Merge pull request #169 from flatbmx/1.6.x

Allow users to build/destroy in safezone if they can build in a worldguard region.
This commit is contained in:
Brett Flannigan 2012-10-09 15:19:23 -07:00
commit 6c5e9cbdc8
4 changed files with 29 additions and 2 deletions

View File

@ -74,6 +74,7 @@ public class Conf
public static boolean removePlayerDataWhenBanned = true; public static boolean removePlayerDataWhenBanned = true;
public static boolean worldGuardChecking = false; public static boolean worldGuardChecking = false;
public static boolean worldGuardBuildPriority = false;
//LWC //LWC
public static boolean lwcIntegration = false; public static boolean lwcIntegration = false;

View File

@ -112,7 +112,7 @@ public class P extends MPlugin
CapiFeatures.setup(); CapiFeatures.setup();
LWCFeatures.setup(); LWCFeatures.setup();
if(Conf.worldGuardChecking) if(Conf.worldGuardChecking || Conf.worldGuardBuildPriority)
{ {
Worldguard.init(this); Worldguard.init(this);
} }

View File

@ -75,7 +75,26 @@ public class Worldguard
ApplicableRegionSet set = regionManager.getApplicableRegions(pt); ApplicableRegionSet set = regionManager.getApplicableRegions(pt);
return set.allows(DefaultFlag.PVP); 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 // Check for Regions in chunk the chunk
// Returns: // Returns:
// True: Regions found within chunk // True: Regions found within chunk

View File

@ -20,6 +20,7 @@ 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.P; import com.massivecraft.factions.P;
import com.massivecraft.factions.integration.Worldguard;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Relation; import com.massivecraft.factions.struct.Relation;
@ -182,6 +183,12 @@ public class FactionsBlockListener implements Listener
} }
else if (otherFaction.isSafeZone()) else if (otherFaction.isSafeZone())
{ {
if (Conf.worldGuardBuildPriority)
{
if (Worldguard.playerCanBuild(player, location))
return true;
}
if (!Conf.safeZoneDenyBuild || Permission.MANAGE_SAFE_ZONE.has(player)) if (!Conf.safeZoneDenyBuild || Permission.MANAGE_SAFE_ZONE.has(player))
return true; return true;