mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-24 11:36:11 +01:00
Undeprecated ApplicableRegionSet.allows(StateFlag)
This commit is contained in:
parent
e9d85da691
commit
65834a2087
@ -82,12 +82,10 @@ public boolean canUse(LocalPlayer player) {
|
|||||||
* Gets the state of a state flag. This cannot be used for the build flag.
|
* Gets the state of a state flag. This cannot be used for the build flag.
|
||||||
*
|
*
|
||||||
* @see #allows(com.sk89q.worldguard.protection.flags.StateFlag, com.sk89q.worldguard.LocalPlayer)
|
* @see #allows(com.sk89q.worldguard.protection.flags.StateFlag, com.sk89q.worldguard.LocalPlayer)
|
||||||
* @deprecated use the {@link #allows(StateFlag, LocalPlayer)} that takes a player
|
|
||||||
* @param flag flag to check
|
* @param flag flag to check
|
||||||
* @return whether it is allowed
|
* @return whether it is allowed
|
||||||
* @throws IllegalArgumentException if the build flag is given
|
* @throws IllegalArgumentException if the build flag is given
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
|
||||||
public boolean allows(StateFlag flag) {
|
public boolean allows(StateFlag flag) {
|
||||||
if (flag == DefaultFlag.BUILD) {
|
if (flag == DefaultFlag.BUILD) {
|
||||||
throw new IllegalArgumentException("Can't use build flag with allows()");
|
throw new IllegalArgumentException("Can't use build flag with allows()");
|
||||||
@ -156,6 +154,7 @@ private boolean internalGetState(StateFlag flag, LocalPlayer player,
|
|||||||
RegionGroupFlag groupFlag,
|
RegionGroupFlag groupFlag,
|
||||||
LocalPlayer groupPlayer) {
|
LocalPlayer groupPlayer) {
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
|
boolean hasFlagDefined = false;
|
||||||
boolean allowed = false; // Used for ALLOW override
|
boolean allowed = false; // Used for ALLOW override
|
||||||
boolean def = flag.getDefault();
|
boolean def = flag.getDefault();
|
||||||
|
|
||||||
@ -204,7 +203,7 @@ private boolean internalGetState(StateFlag flag, LocalPlayer player,
|
|||||||
ProtectedRegion region = it.next();
|
ProtectedRegion region = it.next();
|
||||||
|
|
||||||
// Ignore lower priority regions
|
// Ignore lower priority regions
|
||||||
if (found && region.getPriority() < lastPriority) {
|
if (hasFlagDefined && region.getPriority() < lastPriority) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,6 +238,7 @@ private boolean internalGetState(StateFlag flag, LocalPlayer player,
|
|||||||
if (v == State.ALLOW) {
|
if (v == State.ALLOW) {
|
||||||
allowed = true;
|
allowed = true;
|
||||||
found = true;
|
found = true;
|
||||||
|
hasFlagDefined = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,9 +320,10 @@ public <T extends Flag<V>, V> V getFlag(T flag) {
|
|||||||
clearParents(needsClear, hasCleared, region);
|
clearParents(needsClear, hasCleared, region);
|
||||||
|
|
||||||
needsClear.put(region, region.getFlag(flag));
|
needsClear.put(region, region.getFlag(flag));
|
||||||
}
|
|
||||||
|
|
||||||
found = true;
|
found = true;
|
||||||
|
}
|
||||||
|
|
||||||
lastPriority = region.getPriority();
|
lastPriority = region.getPriority();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,71 @@
|
|||||||
|
// $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.worldedit.BlockVector;
|
||||||
|
import com.sk89q.worldguard.protection.regions.GlobalProtectedRegion;
|
||||||
|
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||||
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
public class MockApplicableRegionSet {
|
||||||
|
|
||||||
|
private TreeSet<ProtectedRegion> regions = new TreeSet<ProtectedRegion>();
|
||||||
|
private ProtectedRegion global;
|
||||||
|
private int id = 0;
|
||||||
|
|
||||||
|
public void add(ProtectedRegion region) {
|
||||||
|
regions.add(region);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProtectedRegion global() {
|
||||||
|
global = new GlobalProtectedRegion("__global__");
|
||||||
|
return global;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProtectedRegion add(int priority) {
|
||||||
|
ProtectedRegion region = new ProtectedCuboidRegion(getNextId(),
|
||||||
|
new BlockVector(0, 0, 0), new BlockVector(1, 1, 1));
|
||||||
|
region.setPriority(priority);
|
||||||
|
add(region);
|
||||||
|
return region;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProtectedRegion add(int priority, ProtectedRegion parent)
|
||||||
|
throws ProtectedRegion.CircularInheritanceException {
|
||||||
|
ProtectedRegion region = new ProtectedCuboidRegion(getNextId(),
|
||||||
|
new BlockVector(0, 0, 0), new BlockVector(1, 1, 1));
|
||||||
|
region.setPriority(priority);
|
||||||
|
region.setParent(parent);
|
||||||
|
add(region);
|
||||||
|
return region;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApplicableRegionSet getApplicableSet() {
|
||||||
|
return new ApplicableRegionSet(regions, global);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getNextId() {
|
||||||
|
id++;
|
||||||
|
return "#REGION_" + id;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user