Skip to content

Commit

Permalink
Merge branch 'EngineHub:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
7man7LMYT committed May 16, 2021
2 parents b13452f + c4e76af commit a46f749
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,26 +90,15 @@ public boolean isIndirect() {
}

/**
* Return whether a cause is known. This method will return true if
* the list of causes is empty or the list of causes only contains
* objects that really are not root causes (i.e primed TNT).
* Return whether a cause is known. This method will return false if
* the list of causes is empty or the root cause is really not known
* (e.g. primed TNT).
*
* @return true if known
*/
public boolean isKnown() {
if (causes.isEmpty()) {
return false;
}

boolean found = false;
for (Object object : causes) {
if (!(object instanceof TNTPrimed) && !(object instanceof Vehicle)) {
found = true;
break;
}
}

return found;
Object object = getRootCause();
return !(object == null || object instanceof TNTPrimed || object instanceof Vehicle);
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public void removePlayer(LocalPlayer player) {
@Override
public boolean contains(LocalPlayer player) {
checkNotNull(player);
return contains(player.getName().trim().toLowerCase()) || contains(player.getUniqueId());
return contains(player.getUniqueId()) || (!names.isEmpty() && contains(player.getName()));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,14 @@ private Iterable<ProtectedRegion> getApplicable() {
/**
* Return the membership status of the given subject, indicating
* whether there are no (counted) regions in the list of regions,
* whether the subject is a member of all regions, or whether
* the region is not a member of all regions.
* whether the subject is a member of all (counted) regions, or
* whether the subject is not a member of all (counted) regions.
*
* <p>A region is "counted" if it doesn't have the
* {@link Flags#PASSTHROUGH} flag set to {@code ALLOW}. (The
* explicit purpose of the PASSTHROUGH flag is to have the region
* be skipped over in this check.)</p>
* {@link Flags#PASSTHROUGH} flag set to {@code ALLOW} and if
* there isn't another "counted" region with a higher priority.
* (The explicit purpose of the PASSTHROUGH flag is to have the
* region be skipped over in this check.)</p>
*
* <p>This method is mostly for internal use. It's not particularly
* useful.</p>
Expand All @@ -113,11 +114,13 @@ public Result getMembership(RegionAssociable subject) {
Set<ProtectedRegion> ignoredRegions = Sets.newHashSet();

for (ProtectedRegion region : getApplicable()) {
int priority = getPriority(region);

// Don't consider lower priorities below minimumPriority
// (which starts at Integer.MIN_VALUE). A region that "counts"
// (has the flag set OR has members) will raise minimumPriority
// to its own priority.
if (getPriority(region) < minimumPriority) {
if (priority < minimumPriority) {
break;
}

Expand All @@ -130,7 +133,7 @@ public Result getMembership(RegionAssociable subject) {
continue;
}

minimumPriority = getPriority(region);
minimumPriority = priority;

boolean member = RegionGroup.MEMBERS.contains(subject.getAssociation(Collections.singletonList(region)));

Expand Down Expand Up @@ -255,7 +258,9 @@ public <V, K> V queryMapValue(@Nullable RegionAssociable subject, MapFlag<K, V>
Set<ProtectedRegion> ignoredParents = new HashSet<>();

for(ProtectedRegion region : getApplicable()) {
if (getPriority(region) < minimumPriority) {
int priority = getPriority(region);

if (priority < minimumPriority) {
break;
}

Expand All @@ -266,12 +271,12 @@ public <V, K> V queryMapValue(@Nullable RegionAssociable subject, MapFlag<K, V>
V effectiveValue = getEffectiveMapValue(region, flag, key, subject);

if (effectiveValue != null) {
minimumPriority = getPriority(region);
minimumPriority = priority;
consideredValues.put(region, effectiveValue);
} else if (fallback != null) {
effectiveValue = getEffectiveFlag(region, fallback, subject);
if (effectiveValue != null) {
minimumPriority = getPriority(region);
minimumPriority = priority;
fallbackValues.put(region, effectiveValue);
}
}
Expand Down Expand Up @@ -388,7 +393,9 @@ private <V> Collection<V> queryAllValues(@Nullable RegionAssociable subject, Fla
Set<ProtectedRegion> ignoredParents = new HashSet<>();

for (ProtectedRegion region : getApplicable()) {
if (getPriority(region) < minimumPriority) {
int priority = getPriority(region);

if (priority < minimumPriority) {
break;
}

Expand All @@ -397,7 +404,6 @@ private <V> Collection<V> queryAllValues(@Nullable RegionAssociable subject, Fla
}

V value = getEffectiveFlag(region, flag, subject);
int priority = getPriority(region);

if (value != null) {
minimumPriority = priority;
Expand All @@ -415,7 +421,7 @@ private <V> Collection<V> queryAllValues(@Nullable RegionAssociable subject, Fla
// PASSTHROUGH is not set to ALLOW
if (priority != minimumPriority && flag.implicitlySetWithMembership()
&& getEffectiveFlag(region, Flags.PASSTHROUGH, subject) != State.ALLOW) {
minimumPriority = getPriority(region);
minimumPriority = priority;
}
}

Expand Down

0 comments on commit a46f749

Please sign in to comment.