mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-28 05:25:20 +01:00
updated protection classes for getIntersectingRegions()
This commit is contained in:
parent
09a150b6e9
commit
65c0d77d3e
@ -149,17 +149,16 @@ public ApplicableRegionSet getApplicableRegions(Vector pt) {
|
||||
public ApplicableRegionSet getApplicableRegions(ProtectedRegion checkRegion) {
|
||||
|
||||
List<ProtectedRegion> appRegions = new ArrayList<ProtectedRegion>();
|
||||
appRegions.addAll(regions.values());
|
||||
|
||||
for (ProtectedRegion region : regions.values()) {
|
||||
try {
|
||||
if (region.intersectsWith(checkRegion)) {
|
||||
appRegions.add(region);
|
||||
}
|
||||
} catch (UnsupportedIntersectionException ex) {
|
||||
}
|
||||
List<ProtectedRegion> intersectRegions;
|
||||
try {
|
||||
intersectRegions = checkRegion.getIntersectingRegions(appRegions);
|
||||
} catch (Exception e) {
|
||||
intersectRegions = new ArrayList<ProtectedRegion>();
|
||||
}
|
||||
|
||||
return new ApplicableRegionSet(appRegions, global);
|
||||
return new ApplicableRegionSet(intersectRegions, global);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -188,22 +187,26 @@ public List<String> getApplicableRegionsIDs(Vector pt) {
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean overlapsUnownedRegion(ProtectedRegion region, LocalPlayer player) {
|
||||
public boolean overlapsUnownedRegion(ProtectedRegion checkRegion, LocalPlayer player) {
|
||||
|
||||
List<ProtectedRegion> appRegions = new ArrayList<ProtectedRegion>();
|
||||
|
||||
for (ProtectedRegion other : regions.values()) {
|
||||
if (other.getOwners().contains(player)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
if (region.intersectsWith(other)) {
|
||||
return true;
|
||||
}
|
||||
} catch (UnsupportedIntersectionException e) {
|
||||
// TODO: Maybe do something here
|
||||
}
|
||||
appRegions.add(other);
|
||||
}
|
||||
|
||||
return false;
|
||||
List<ProtectedRegion> intersectRegions;
|
||||
try {
|
||||
intersectRegions = checkRegion.getIntersectingRegions(appRegions);
|
||||
} catch (Exception e) {
|
||||
intersectRegions = new ArrayList<ProtectedRegion>();
|
||||
}
|
||||
|
||||
return intersectRegions.size() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -157,17 +157,16 @@ public ApplicableRegionSet getApplicableRegions(Vector pt) {
|
||||
|
||||
public ApplicableRegionSet getApplicableRegions(ProtectedRegion checkRegion) {
|
||||
List<ProtectedRegion> appRegions = new ArrayList<ProtectedRegion>();
|
||||
appRegions.addAll(regions.values());
|
||||
|
||||
for (ProtectedRegion region : regions.values()) {
|
||||
try {
|
||||
if (region.intersectsWith(checkRegion)) {
|
||||
appRegions.add(region);
|
||||
}
|
||||
} catch (UnsupportedIntersectionException ex) {
|
||||
}
|
||||
List<ProtectedRegion> intersectRegions;
|
||||
try {
|
||||
intersectRegions = checkRegion.getIntersectingRegions(appRegions);
|
||||
} catch (Exception e) {
|
||||
intersectRegions = new ArrayList<ProtectedRegion>();
|
||||
}
|
||||
|
||||
return new ApplicableRegionSet(appRegions, global);
|
||||
return new ApplicableRegionSet(intersectRegions, global);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -199,22 +198,25 @@ public List<String> getApplicableRegionsIDs(Vector pt) {
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean overlapsUnownedRegion(ProtectedRegion region, LocalPlayer player) {
|
||||
public boolean overlapsUnownedRegion(ProtectedRegion checkRegion, LocalPlayer player) {
|
||||
List<ProtectedRegion> appRegions = new ArrayList<ProtectedRegion>();
|
||||
|
||||
for (ProtectedRegion other : regions.values()) {
|
||||
if (other.getOwners().contains(player)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
if (region.intersectsWith(other)) {
|
||||
return true;
|
||||
}
|
||||
} catch (UnsupportedIntersectionException e) {
|
||||
// TODO: Maybe do something here
|
||||
}
|
||||
appRegions.add(other);
|
||||
}
|
||||
|
||||
return false;
|
||||
List<ProtectedRegion> intersectRegions;
|
||||
try {
|
||||
intersectRegions = checkRegion.getIntersectingRegions(appRegions);
|
||||
} catch (Exception e) {
|
||||
intersectRegions = new ArrayList<ProtectedRegion>();
|
||||
}
|
||||
|
||||
return intersectRegions.size() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldguard.protection.UnsupportedIntersectionException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Represents a cuboid region that can be protected.
|
||||
@ -100,13 +101,8 @@ public boolean contains(Vector pt) {
|
||||
&& z >= min.getBlockZ() && z <= max.getBlockZ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if two region intersects.
|
||||
*
|
||||
* @param region
|
||||
* @throws UnsupportedIntersectionException
|
||||
* @return
|
||||
*/
|
||||
|
||||
/*
|
||||
public boolean intersectsWith(ProtectedRegion region) throws UnsupportedIntersectionException {
|
||||
|
||||
if (region instanceof ProtectedCuboidRegion) {
|
||||
@ -129,6 +125,12 @@ public boolean intersectsWith(ProtectedRegion region) throws UnsupportedIntersec
|
||||
throw new UnsupportedIntersectionException();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
public List<ProtectedRegion> getIntersectingRegions(List<ProtectedRegion> regions) throws UnsupportedIntersectionException {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the type of region as a user-friendly name.
|
||||
@ -152,4 +154,6 @@ public int countBlocks() {
|
||||
int volume = xLength * yLength * zLength;
|
||||
return volume;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -131,24 +131,13 @@ public boolean contains(Vector pt) {
|
||||
return inside;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if two region intersects.
|
||||
*
|
||||
* @param region
|
||||
* @throws UnsupportedIntersectionException
|
||||
* @return
|
||||
*/
|
||||
public boolean intersectsWith(ProtectedRegion region) throws UnsupportedIntersectionException {
|
||||
|
||||
if (region instanceof ProtectedCuboidRegion) {
|
||||
throw new UnsupportedIntersectionException();
|
||||
} else if (region instanceof ProtectedPolygonalRegion) {
|
||||
throw new UnsupportedIntersectionException();
|
||||
} else {
|
||||
throw new UnsupportedIntersectionException();
|
||||
}
|
||||
|
||||
|
||||
public List<ProtectedRegion> getIntersectingRegions(List<ProtectedRegion> regions) throws UnsupportedIntersectionException {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the type of region as a user-friendly name.
|
||||
*
|
||||
|
@ -24,6 +24,7 @@
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||
import com.sk89q.worldguard.protection.UnsupportedIntersectionException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Represents a region of any shape and size that can be protected.
|
||||
@ -298,15 +299,9 @@ public int compareTo(ProtectedRegion other) {
|
||||
*/
|
||||
public abstract String getTypeName();
|
||||
|
||||
/**
|
||||
* Checks if two region intersects.
|
||||
*
|
||||
* @param region
|
||||
* @throws UnsupportedIntersectionException
|
||||
* @return
|
||||
*/
|
||||
public abstract boolean intersectsWith(ProtectedRegion region) throws UnsupportedIntersectionException;
|
||||
|
||||
|
||||
public abstract List<ProtectedRegion> getIntersectingRegions(List<ProtectedRegion> regions) throws UnsupportedIntersectionException;
|
||||
|
||||
|
||||
/**
|
||||
* Thrown when setting a parent would create a circular inheritance
|
||||
|
Loading…
Reference in New Issue
Block a user