mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-24 03:25:24 +01:00
Changed how ApplicableRegionSet iterated over the region set, allowing it to be reused.
This commit is contained in:
parent
ce1a15e6ea
commit
43489ca087
@ -20,8 +20,9 @@
|
|||||||
package com.sk89q.worldguard.protection;
|
package com.sk89q.worldguard.protection;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.SortedMap;
|
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldguard.LocalPlayer;
|
import com.sk89q.worldguard.LocalPlayer;
|
||||||
import com.sk89q.worldguard.protection.AreaFlags.State;
|
import com.sk89q.worldguard.protection.AreaFlags.State;
|
||||||
@ -34,7 +35,7 @@
|
|||||||
public class ApplicableRegionSet {
|
public class ApplicableRegionSet {
|
||||||
private GlobalFlags global;
|
private GlobalFlags global;
|
||||||
private Vector pt;
|
private Vector pt;
|
||||||
private SortedMap<String,ProtectedRegion> regions;
|
private Iterator<ProtectedRegion> applicable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the object.
|
* Construct the object.
|
||||||
@ -43,10 +44,10 @@ public class ApplicableRegionSet {
|
|||||||
* @param regions
|
* @param regions
|
||||||
* @param global
|
* @param global
|
||||||
*/
|
*/
|
||||||
public ApplicableRegionSet(Vector pt, SortedMap<String,ProtectedRegion> regions,
|
public ApplicableRegionSet(Vector pt, Iterator<ProtectedRegion> applicable,
|
||||||
GlobalFlags global) {
|
GlobalFlags global) {
|
||||||
this.pt = pt;
|
this.pt = pt;
|
||||||
this.regions = regions;
|
this.applicable = applicable;
|
||||||
this.global = global;
|
this.global = global;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +112,9 @@ private boolean isFlagAllowed(String flag, boolean def, LocalPlayer player) {
|
|||||||
Set<ProtectedRegion> needsClear = new HashSet<ProtectedRegion>();
|
Set<ProtectedRegion> needsClear = new HashSet<ProtectedRegion>();
|
||||||
Set<ProtectedRegion> hasCleared = new HashSet<ProtectedRegion>();
|
Set<ProtectedRegion> hasCleared = new HashSet<ProtectedRegion>();
|
||||||
|
|
||||||
for (ProtectedRegion region : regions.values()) {
|
while (applicable.hasNext()) {
|
||||||
|
ProtectedRegion region = applicable.next();
|
||||||
|
|
||||||
// Ignore non-build regions
|
// Ignore non-build regions
|
||||||
if (player != null && region.getFlags().get(AreaFlags.FLAG_PASSTHROUGH) == State.ALLOW) {
|
if (player != null && region.getFlags().get(AreaFlags.FLAG_PASSTHROUGH) == State.ALLOW) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -38,7 +38,7 @@ public class FlatRegionManager implements RegionManager {
|
|||||||
/**
|
/**
|
||||||
* List of protected regions.
|
* List of protected regions.
|
||||||
*/
|
*/
|
||||||
private SortedMap<String,ProtectedRegion> regions;
|
private Map<String,ProtectedRegion> regions;
|
||||||
/**
|
/**
|
||||||
* Global flags.
|
* Global flags.
|
||||||
*/
|
*/
|
||||||
@ -61,7 +61,6 @@ public Map<String,ProtectedRegion> getRegions() {
|
|||||||
return regions;
|
return regions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a list of protected regions.
|
* Set a list of protected regions.
|
||||||
*
|
*
|
||||||
@ -70,6 +69,7 @@ public Map<String,ProtectedRegion> getRegions() {
|
|||||||
public void setRegions(Map<String,ProtectedRegion> regions) {
|
public void setRegions(Map<String,ProtectedRegion> regions) {
|
||||||
this.regions = new TreeMap<String,ProtectedRegion>(regions);
|
this.regions = new TreeMap<String,ProtectedRegion>(regions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a region.
|
* Adds a region.
|
||||||
*
|
*
|
||||||
@ -125,7 +125,7 @@ public ProtectedRegion getRegion(String id) {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public ApplicableRegionSet getApplicableRegions(Vector pt) {
|
public ApplicableRegionSet getApplicableRegions(Vector pt) {
|
||||||
return new ApplicableRegionSet(pt, regions, global);
|
return new ApplicableRegionSet(pt, regions.values().iterator(), global);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -79,6 +79,20 @@ public String getId() {
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the lower point of the cuboid.
|
||||||
|
*
|
||||||
|
* @return min point
|
||||||
|
*/
|
||||||
|
public abstract BlockVector getMinimumPoint();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the upper point of the cuboid.
|
||||||
|
*
|
||||||
|
* @return max point
|
||||||
|
*/
|
||||||
|
public abstract BlockVector getMaximumPoint();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the priority
|
* @return the priority
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user