only detect max priority once

This commit is contained in:
JOO200 2020-07-30 20:37:49 +02:00
parent 5162ce3dbd
commit 85c5f53d29
1 changed files with 2 additions and 2 deletions

View File

@ -51,7 +51,7 @@ public class DelayedRegionOverlapAssociation implements RegionAssociable {
/**
* Create a new instance.
* @param query the query
* @param query the query
* @param world the world
* @param location the location
*/
@ -70,6 +70,7 @@ public class DelayedRegionOverlapAssociation implements RegionAssociable {
ApplicableRegionSet result = query.getApplicableRegions(location);
source = result.getRegions();
}
int maxPriority = source.stream().mapToInt(ProtectedRegion::getPriority).max().orElse(0);
for (ProtectedRegion region : regions) {
if ((region.getId().equals(ProtectedRegion.GLOBAL_REGION) && source.isEmpty())) {
@ -79,7 +80,6 @@ public class DelayedRegionOverlapAssociation implements RegionAssociable {
if (source.contains(region)) {
if (betterAssociationMode) {
int priority = region.getPriority();
int maxPriority = source.stream().mapToInt(ProtectedRegion::getPriority).max().orElse(0);
if (priority == maxPriority) return Association.OWNER;
} else {
return Association.OWNER;