mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-24 03:25:24 +01:00
Fix incorrect region group inheritance and broken flag override in children.
This commit is contained in:
parent
f516fd5e54
commit
01276dfc62
@ -24,6 +24,7 @@
|
|||||||
import com.sk89q.worldguard.protection.association.RegionAssociable;
|
import com.sk89q.worldguard.protection.association.RegionAssociable;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public abstract class LocalPlayer implements RegionAssociable {
|
public abstract class LocalPlayer implements RegionAssociable {
|
||||||
@ -94,16 +95,20 @@ public abstract class LocalPlayer implements RegionAssociable {
|
|||||||
public abstract boolean hasPermission(String perm);
|
public abstract boolean hasPermission(String perm);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Association getAssociation(ProtectedRegion region) {
|
public Association getAssociation(List<ProtectedRegion> regions) {
|
||||||
|
boolean member = false;
|
||||||
|
|
||||||
|
for (ProtectedRegion region : regions) {
|
||||||
if (region.isOwner(this)) {
|
if (region.isOwner(this)) {
|
||||||
return Association.OWNER;
|
return Association.OWNER;
|
||||||
} else if (region.isMember(this)) {
|
} else if (!member && region.isMember(this)) {
|
||||||
return Association.MEMBER;
|
member = true;
|
||||||
} else {
|
|
||||||
return Association.NON_MEMBER;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return member ? Association.MEMBER : Association.NON_MEMBER;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
return obj instanceof LocalPlayer && ((LocalPlayer) obj).getName().equals(getName());
|
return obj instanceof LocalPlayer && ((LocalPlayer) obj).getName().equals(getName());
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
@ -36,7 +37,7 @@
|
|||||||
* region is in a set of source regions.
|
* region is in a set of source regions.
|
||||||
*
|
*
|
||||||
* <p>This class only performs a spatial query if its
|
* <p>This class only performs a spatial query if its
|
||||||
* {@link #getAssociation(ProtectedRegion)} method is called.</p>
|
* {@link #getAssociation(List)} method is called.</p>
|
||||||
*/
|
*/
|
||||||
public class DelayedRegionOverlapAssociation implements RegionAssociable {
|
public class DelayedRegionOverlapAssociation implements RegionAssociable {
|
||||||
|
|
||||||
@ -59,17 +60,19 @@ public DelayedRegionOverlapAssociation(RegionQuery query, Location location) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Association getAssociation(ProtectedRegion region) {
|
public Association getAssociation(List<ProtectedRegion> regions) {
|
||||||
if (source == null) {
|
if (source == null) {
|
||||||
ApplicableRegionSet result = query.getApplicableRegions(location);
|
ApplicableRegionSet result = query.getApplicableRegions(location);
|
||||||
source = result.getRegions();
|
source = result.getRegions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (ProtectedRegion region : regions) {
|
||||||
if ((region.getId().equals(ProtectedRegion.GLOBAL_REGION) && source.isEmpty()) || source.contains(region)) {
|
if ((region.getId().equals(ProtectedRegion.GLOBAL_REGION) && source.isEmpty()) || source.contains(region)) {
|
||||||
return Association.OWNER;
|
return Association.OWNER;
|
||||||
} else {
|
|
||||||
return Association.NON_MEMBER;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Association.NON_MEMBER;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,13 +31,7 @@
|
|||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
@ -157,7 +151,7 @@ public Result getMembership(RegionAssociable subject) {
|
|||||||
foundApplicableRegion = true;
|
foundApplicableRegion = true;
|
||||||
|
|
||||||
if (!hasCleared.contains(region)) {
|
if (!hasCleared.contains(region)) {
|
||||||
if (!RegionGroup.MEMBERS.contains(subject.getAssociation(region))) {
|
if (!RegionGroup.MEMBERS.contains(subject.getAssociation(Arrays.asList(region)))) {
|
||||||
needsClear.add(region);
|
needsClear.add(region);
|
||||||
} else {
|
} else {
|
||||||
// Need to clear all parents
|
// Need to clear all parents
|
||||||
@ -330,12 +324,6 @@ public <V> Collection<V> queryAllValues(@Nullable RegionAssociable subject, Flag
|
|||||||
|
|
||||||
ignoreValuesOfParents(consideredValues, ignoredRegions, region);
|
ignoreValuesOfParents(consideredValues, ignoredRegions, region);
|
||||||
consideredValues.put(region, value);
|
consideredValues.put(region, value);
|
||||||
|
|
||||||
if (value == State.DENY) {
|
|
||||||
// Since DENY overrides all other values, there
|
|
||||||
// is no need to consider any further regions
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -411,7 +399,11 @@ public <V> V getEffectiveFlag(final ProtectedRegion region, Flag<V> flag, @Nulla
|
|||||||
|
|
||||||
ProtectedRegion current = region;
|
ProtectedRegion current = region;
|
||||||
|
|
||||||
|
List<ProtectedRegion> seen = new ArrayList<ProtectedRegion>();
|
||||||
|
|
||||||
while (current != null) {
|
while (current != null) {
|
||||||
|
seen.add(current);
|
||||||
|
|
||||||
V value = current.getFlag(flag);
|
V value = current.getFlag(flag);
|
||||||
|
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
@ -427,7 +419,7 @@ public <V> V getEffectiveFlag(final ProtectedRegion region, Flag<V> flag, @Nulla
|
|||||||
use = false;
|
use = false;
|
||||||
} else if (subject == null) {
|
} else if (subject == null) {
|
||||||
use = group.contains(Association.NON_MEMBER);
|
use = group.contains(Association.NON_MEMBER);
|
||||||
} else if (!group.contains(subject.getAssociation(region))) {
|
} else if (!group.contains(subject.getAssociation(seen))) {
|
||||||
use = false;
|
use = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
import com.sk89q.worldguard.domains.Association;
|
import com.sk89q.worldguard.domains.Association;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
class ConstantAssociation implements RegionAssociable {
|
class ConstantAssociation implements RegionAssociable {
|
||||||
|
|
||||||
private final Association association;
|
private final Association association;
|
||||||
@ -31,7 +33,7 @@ class ConstantAssociation implements RegionAssociable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Association getAssociation(ProtectedRegion region) {
|
public Association getAssociation(List<ProtectedRegion> regions) {
|
||||||
return association;
|
return association;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,17 +22,19 @@
|
|||||||
import com.sk89q.worldguard.domains.Association;
|
import com.sk89q.worldguard.domains.Association;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An object that can have membership in a region.
|
* An object that can have membership in a region.
|
||||||
*/
|
*/
|
||||||
public interface RegionAssociable {
|
public interface RegionAssociable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the most specific association level for the input region.
|
* Get the highest association level for the input regions.
|
||||||
*
|
*
|
||||||
* @param region the input region
|
* @param regions a list of regions
|
||||||
* @return the most specific membership level
|
* @return the highest membership level
|
||||||
*/
|
*/
|
||||||
Association getAssociation(ProtectedRegion region);
|
Association getAssociation(List<ProtectedRegion> regions);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
import com.sk89q.worldguard.domains.Association;
|
import com.sk89q.worldguard.domains.Association;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
@ -45,12 +46,14 @@ public RegionOverlapAssociation(Set<ProtectedRegion> source) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Association getAssociation(ProtectedRegion region) {
|
public Association getAssociation(List<ProtectedRegion> regions) {
|
||||||
|
for (ProtectedRegion region : regions) {
|
||||||
if (source.contains(region)) {
|
if (source.contains(region)) {
|
||||||
return Association.OWNER;
|
return Association.OWNER;
|
||||||
} else {
|
|
||||||
return Association.NON_MEMBER;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Association.NON_MEMBER;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user