mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-29 04:28:04 +01:00
Fix child regions not inheriting parent flags.
This also fixes a unit test.
This commit is contained in:
parent
3f16fef57e
commit
d3f3489c7e
@ -251,8 +251,7 @@ private boolean internalGetState(StateFlag flag, @Nullable LocalPlayer player, @
|
||||
lastPriority = region.getPriority();
|
||||
|
||||
// Ignore non-build regions
|
||||
if (player != null
|
||||
&& region.getFlag(DefaultFlag.PASSTHROUGH) == State.ALLOW) {
|
||||
if (player != null && getStateFlagIncludingParents(region, DefaultFlag.PASSTHROUGH) == State.ALLOW) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -267,7 +266,7 @@ private boolean internalGetState(StateFlag flag, @Nullable LocalPlayer player, @
|
||||
}
|
||||
}
|
||||
|
||||
State v = region.getFlag(flag);
|
||||
State v = getStateFlagIncludingParents(region, flag);
|
||||
|
||||
// Allow DENY to override everything
|
||||
if (v == State.DENY) {
|
||||
@ -327,6 +326,28 @@ private void clearParents(Set<ProtectedRegion> needsClear, Set<ProtectedRegion>
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a region's state flag, checking parent regions until a value for the
|
||||
* flag can be found (if one even exists).
|
||||
*
|
||||
* @param region the region
|
||||
* @param flag the flag
|
||||
* @return the value
|
||||
*/
|
||||
private static State getStateFlagIncludingParents(ProtectedRegion region, StateFlag flag) {
|
||||
while (region != null) {
|
||||
State value = region.getFlag(flag);
|
||||
|
||||
if (value != null) {
|
||||
return value;
|
||||
}
|
||||
|
||||
region = region.getParent();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of a flag. Do not use this for state flags
|
||||
* (use {@link #allows(StateFlag, LocalPlayer)} for that).
|
||||
|
@ -19,8 +19,6 @@
|
||||
|
||||
package com.sk89q.worldguard.protection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import org.junit.Before;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
@ -29,9 +27,17 @@
|
||||
import com.sk89q.worldguard.protection.flags.DefaultFlag;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.*;
|
||||
import com.sk89q.worldguard.protection.regions.GlobalProtectedRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedPolygonalRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public abstract class RegionPriorityTest {
|
||||
static String COURTYARD_ID = "courtyard";
|
||||
@ -143,7 +149,7 @@ public void testPriorities() throws Exception {
|
||||
public void testPriorities2() throws Exception {
|
||||
ApplicableRegionSet appl;
|
||||
|
||||
fountain.setPriority(0);
|
||||
courtyard.setPriority(0);
|
||||
fountain.setPriority(5);
|
||||
|
||||
appl = manager.getApplicableRegions(inCourtyard);
|
||||
|
Loading…
Reference in New Issue
Block a user