diff --git a/worldguard-core/src/test/java/com/sk89q/worldguard/protection/RegionOverlapTest.java b/worldguard-core/src/test/java/com/sk89q/worldguard/protection/RegionOverlapTest.java index b0549b15..7bfbeddb 100644 --- a/worldguard-core/src/test/java/com/sk89q/worldguard/protection/RegionOverlapTest.java +++ b/worldguard-core/src/test/java/com/sk89q/worldguard/protection/RegionOverlapTest.java @@ -27,6 +27,7 @@ import com.sk89q.worldguard.TestPlayer; import com.sk89q.worldguard.WorldGuard; import com.sk89q.worldguard.domains.DefaultDomain; +import com.sk89q.worldguard.protection.association.RegionOverlapAssociation; import com.sk89q.worldguard.protection.flags.Flags; import com.sk89q.worldguard.protection.flags.StateFlag; import com.sk89q.worldguard.protection.flags.registry.FlagRegistry; @@ -168,10 +169,6 @@ public void testPlayer1BuildAccess() { public void testPlayer2BuildAccess() { ApplicableRegionSet appl; - HashSet test = new HashSet<>(); - test.add(courtyard); - test.add(fountain); - // Outside appl = manager.getApplicableRegions(outside); assertTrue(appl.testState(player2, Flags.BUILD)); @@ -182,4 +179,61 @@ public void testPlayer2BuildAccess() { appl = manager.getApplicableRegions(inFountain); assertTrue(appl.testState(player2, Flags.BUILD)); } + + @Test + public void testNonPlayerBuildAccessInOneRegion() { + ApplicableRegionSet appl; + + HashSet source = new HashSet<>(); + source.add(courtyard); + RegionOverlapAssociation assoc = new RegionOverlapAssociation(source); + + // Outside + appl = manager.getApplicableRegions(outside); + assertTrue(appl.testState(assoc, Flags.BUILD)); + // Inside courtyard + appl = manager.getApplicableRegions(inCourtyard); + assertTrue(appl.testState(assoc, Flags.BUILD)); + // Inside fountain + appl = manager.getApplicableRegions(inFountain); + assertFalse(appl.testState(assoc, Flags.BUILD)); + } + + @Test + public void testNonPlayerBuildAccessInBothRegions() { + ApplicableRegionSet appl; + + HashSet source = new HashSet<>(); + source.add(fountain); + source.add(courtyard); + RegionOverlapAssociation assoc = new RegionOverlapAssociation(source); + + // Outside + appl = manager.getApplicableRegions(outside); + assertTrue(appl.testState(assoc, Flags.BUILD)); + // Inside courtyard + appl = manager.getApplicableRegions(inCourtyard); + assertTrue(appl.testState(assoc, Flags.BUILD)); + // Inside fountain + appl = manager.getApplicableRegions(inFountain); + assertTrue(appl.testState(assoc, Flags.BUILD)); + } + + @Test + public void testNonPlayerBuildAccessInNoRegions() { + ApplicableRegionSet appl; + + HashSet source = new HashSet<>(); + RegionOverlapAssociation assoc = new RegionOverlapAssociation(source); + + // Outside + appl = manager.getApplicableRegions(outside); + assertTrue(appl.testState(assoc, Flags.BUILD)); + // Inside courtyard + appl = manager.getApplicableRegions(inCourtyard); + assertFalse(appl.testState(assoc, Flags.BUILD)); + // Inside fountain + appl = manager.getApplicableRegions(inFountain); + assertFalse(appl.testState(assoc, Flags.BUILD)); + } }