mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-24 18:19:03 +01:00
getAreaFlag now respects region priority
This commit is contained in:
parent
b90fb6a2b0
commit
23aa6dc743
@ -191,6 +191,7 @@ private boolean isFlagAllowed(String flag, boolean def, LocalPlayer player) {
|
||||
* @param player null to not check owners and members
|
||||
* @return
|
||||
*/
|
||||
// todo : check priorities
|
||||
private String getAreaFlag(String name, String subname, Boolean inherit, LocalPlayer player) {
|
||||
|
||||
int appSize = applicable.size();
|
||||
@ -222,35 +223,38 @@ else if(appSize < 2)
|
||||
}
|
||||
}
|
||||
|
||||
ProtectedRegion region = null;
|
||||
ProtectedRegion childRegion = null;
|
||||
iter = applicable.iterator();
|
||||
|
||||
while (iter.hasNext()) {
|
||||
region = iter.next();
|
||||
ProtectedRegion region = iter.next();
|
||||
if(!parents.contains(region.getId()))
|
||||
{
|
||||
break;
|
||||
if(childRegion == null || childRegion.getPriority() < region.getPriority())
|
||||
{
|
||||
childRegion = region;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (player != null && !region.isMember(player)) {
|
||||
if (player != null && !childRegion.isMember(player)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if(!inherit)
|
||||
{
|
||||
return region.getFlags().getFlag(name, subname);
|
||||
return childRegion.getFlags().getFlag(name, subname);
|
||||
}
|
||||
else
|
||||
{
|
||||
String value;
|
||||
do
|
||||
{
|
||||
value = region.getFlags().getFlag(name, subname);
|
||||
region = region.getParent();
|
||||
value = childRegion.getFlags().getFlag(name, subname);
|
||||
childRegion = childRegion.getParent();
|
||||
|
||||
} while(value == null && region != null);
|
||||
} while(value == null && childRegion != null);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
@ -1,41 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldGuard
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.protection;
|
||||
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import java.util.Comparator;
|
||||
|
||||
class DescendingPriorityComparator implements Comparator<ProtectedRegion> {
|
||||
/**
|
||||
* Compares two regions.
|
||||
*
|
||||
* @param other
|
||||
* @return
|
||||
*/
|
||||
public int compare(ProtectedRegion r1, ProtectedRegion r2) {
|
||||
if (r1.getPriority() == r2.getPriority()) {
|
||||
return 0;
|
||||
} else if (r1.getPriority() > r2.getPriority()) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user