mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-26 02:57:42 +01:00
Force __global__ BUILD flag to NONE.
This is due to the legacy reason of the global region having not been previously processed as a regular region.
This commit is contained in:
parent
bfb3f9e840
commit
a35aaf9659
@ -407,14 +407,20 @@ public int getPriority(final ProtectedRegion region) {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <V> V getEffectiveFlag(final ProtectedRegion region, Flag<V> flag, @Nullable LocalPlayer player) {
|
||||
// The global region normally does not prevent building so
|
||||
// PASSTHROUGH has to be ALLOW, except when people use the global
|
||||
// region as a whitelist
|
||||
if (region == globalRegion && flag == DefaultFlag.PASSTHROUGH) {
|
||||
if (region.hasMembersOrOwners()) {
|
||||
if (region == globalRegion) {
|
||||
if (flag == DefaultFlag.PASSTHROUGH) {
|
||||
// Has members/owners -> the global region acts like
|
||||
// a regular region without PASSTHROUGH
|
||||
if (region.hasMembersOrOwners()) {
|
||||
return null;
|
||||
} else {
|
||||
return (V) State.ALLOW;
|
||||
}
|
||||
|
||||
} else if (flag == DefaultFlag.BUILD) {
|
||||
// Legacy behavior -> we can't let people change BUILD on
|
||||
// the global region
|
||||
return null;
|
||||
} else {
|
||||
return (V) State.ALLOW;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1959,4 +1959,38 @@ public void testGetEffectiveFlagInheritanceAndDifferingGroupsMemberOnParentFlagO
|
||||
assertThat(result.getEffectiveFlag(region, DefaultFlag.FAREWELL_MESSAGE, null), equalTo("everyone"));
|
||||
assertThat(result.getEffectiveFlag(region, DefaultFlag.GREET_MESSAGE, null), equalTo(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetEffectiveFlagGlobalRegionBuild() throws Exception {
|
||||
MockApplicableRegionSet mock = new MockApplicableRegionSet();
|
||||
|
||||
ProtectedRegion global = mock.global();
|
||||
|
||||
FlagValueCalculator result = mock.getFlagCalculator();
|
||||
assertThat(result.getEffectiveFlag(global, DefaultFlag.BUILD, null), equalTo(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetEffectiveFlagGlobalRegionBuildDeny() throws Exception {
|
||||
MockApplicableRegionSet mock = new MockApplicableRegionSet();
|
||||
|
||||
ProtectedRegion global = mock.global();
|
||||
global.setFlag(DefaultFlag.BUILD, State.DENY);
|
||||
|
||||
FlagValueCalculator result = mock.getFlagCalculator();
|
||||
// Cannot let users override BUILD on GLOBAL
|
||||
assertThat(result.getEffectiveFlag(global, DefaultFlag.BUILD, null), equalTo(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetEffectiveFlagGlobalRegionBuildAllow() throws Exception {
|
||||
MockApplicableRegionSet mock = new MockApplicableRegionSet();
|
||||
|
||||
ProtectedRegion global = mock.global();
|
||||
global.setFlag(DefaultFlag.BUILD, State.ALLOW);
|
||||
|
||||
FlagValueCalculator result = mock.getFlagCalculator();
|
||||
// Cannot let users override BUILD on GLOBAL
|
||||
assertThat(result.getEffectiveFlag(global, DefaultFlag.BUILD, null), equalTo(null));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user