fixed tnt block npe thanks to Brettflan, added claim-only-inside-existing-regions and max-region-count-per-player region options, updated ApplicableRegionSet for regions

This commit is contained in:
Redecouverte 2011-02-27 16:24:07 +01:00
parent 2092cc43b3
commit 881846d301
11 changed files with 264 additions and 140 deletions

View File

@ -70,8 +70,10 @@ player-damage:
regions:
enable: on
wand: 287
max-claim-volume: 1000
wand: 287
max-claim-volume: 30000
claim-only-inside-existing-regions: off
max-region-count-per-player: 7
default:
build: on
chest-access: off

View File

@ -261,7 +261,7 @@ public void onEntityExplode(EntityExplodeEvent event) {
}
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(event.getEntity().getWorld().getName());
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(event.getLocation().getWorld().getName());
if (event.getEntity() instanceof LivingEntity) {
@ -278,7 +278,7 @@ public void onEntityExplode(EntityExplodeEvent event) {
if (wcfg.useRegions) {
Vector pt = toVector(event.getEntity().getLocation());
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(event.getEntity().getWorld().getName());
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(event.getLocation().getWorld().getName());
if (!mgr.getApplicableRegions(pt)
.allowsFlag(AreaFlags.FLAG_CREEPER_EXPLOSION)) {
@ -294,7 +294,7 @@ public void onEntityExplode(EntityExplodeEvent event) {
if (wcfg.useRegions && event.getEntity() != null) {
Vector pt = toVector(event.getEntity().getLocation());
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(event.getEntity().getWorld().getName());
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(event.getLocation().getWorld().getName());
if (!mgr.getApplicableRegions(pt)
.allowsFlag(AreaFlags.FLAG_TNT)) {

View File

@ -93,6 +93,8 @@ public class WorldGuardWorldConfiguration {
public boolean buyOnClaim;
public double buyOnClaimPrice;
public int maxClaimVolume;
public boolean claimOnlyInsideExistingRegions;
public int maxRegionCountPerPlayer;
/* Configuration data end */
@ -201,7 +203,9 @@ private void loadConfiguration() {
useRegions = config.getBoolean("regions.enable", true);
regionWand = config.getInt("regions.wand", 287);
maxClaimVolume = config.getInt("regions.max-claim-volume", 1000);
maxClaimVolume = config.getInt("regions.max-claim-volume", 30000);
claimOnlyInsideExistingRegions = config.getBoolean("regions.claim-only-inside-existing-regions", false);
maxRegionCountPerPlayer = config.getInt("regions.max-region-count-per-player", 7);
useiConomy = config.getBoolean("iconomy.enable", false);
buyOnClaim = config.getBoolean("iconomy.buy-on-claim", false);

View File

@ -15,8 +15,7 @@
*
* 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.bukkit.commands;
import com.sk89q.worldedit.BlockVector;
@ -36,6 +35,8 @@
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.nijiko.coelho.iConomy.*;
import com.nijiko.coelho.iConomy.system.*;
import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import java.io.IOException;
import org.bukkit.ChatColor;
@ -70,10 +71,17 @@ public boolean handle(CommandSender sender, String senderName, String command, S
String id = args[0].toLowerCase();
RegionManager mgr = cfg.getWorldGuardPlugin().getGlobalRegionManager().getRegionManager(player.getWorld().getName());
LocalPlayer lPlayer = BukkitPlayer.wrapPlayer(cfg, player);
if (mgr.getRegionCountOfPlayer(lPlayer) >= wcfg.maxRegionCountPerPlayer) {
player.sendMessage(ChatColor.RED + "You own too much regions, delete one first to claim a new one.");
return true;
}
ProtectedRegion existing = mgr.getRegion(id);
if (existing != null) {
if (!existing.getOwners().contains(BukkitPlayer.wrapPlayer(cfg, player))) {
if (!existing.getOwners().contains(lPlayer)) {
player.sendMessage(ChatColor.RED + "You don't own this region.");
return true;
}
@ -100,9 +108,20 @@ public boolean handle(CommandSender sender, String senderName, String command, S
region = new ProtectedCuboidRegion(id, min, max);
}
if (mgr.overlapsUnownedRegion(region, BukkitPlayer.wrapPlayer(cfg, player))) {
player.sendMessage(ChatColor.RED + "This region overlaps with someone else's region.");
return true;
ApplicableRegionSet regions = mgr.getApplicableRegions(region);
if (regions.isAnyRegionAffected()) {
if (!regions.isOwner(lPlayer)) {
player.sendMessage(ChatColor.RED + "This region overlaps with someone else's region.");
return true;
}
}
else
{
if(wcfg.claimOnlyInsideExistingRegions)
{
player.sendMessage(ChatColor.RED + "You may only claim regions inside existing regions that you or your group own.");
return true;
}
}
if (region.countBlocks() > wcfg.maxClaimVolume) {
@ -120,13 +139,13 @@ public boolean handle(CommandSender sender, String senderName, String command, S
double regionCosts = region.countBlocks() * wcfg.buyOnClaimPrice;
if (balance >= regionCosts) {
account.subtract(regionCosts);
player.sendMessage(ChatColor.YELLOW + "You have bought that region for " +
iConomy.getBank().format(regionCosts));
player.sendMessage(ChatColor.YELLOW + "You have bought that region for "
+ iConomy.getBank().format(regionCosts));
account.save();
} else {
player.sendMessage(ChatColor.RED + "You have not enough money.");
player.sendMessage(ChatColor.RED + "The region you want to claim costs " +
iConomy.getBank().format(regionCosts));
player.sendMessage(ChatColor.RED + "The region you want to claim costs "
+ iConomy.getBank().format(regionCosts));
player.sendMessage(ChatColor.RED + "You have " + iConomy.getBank().format(balance));
return true;
}

View File

@ -20,7 +20,6 @@
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import java.util.Iterator;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.protection.regions.AreaFlags;
import com.sk89q.worldguard.protection.regions.AreaFlags.State;
@ -36,7 +35,6 @@
public class ApplicableRegionSet {
private GlobalFlags global;
private Vector pt;
private List<ProtectedRegion> applicable;
private ProtectedRegion affectedRegion;
@ -47,9 +45,7 @@ public class ApplicableRegionSet {
* @param regions
* @param global
*/
public ApplicableRegionSet(Vector pt, List<ProtectedRegion> applicable,
GlobalFlags global) {
this.pt = pt;
public ApplicableRegionSet(List<ProtectedRegion> applicable, GlobalFlags global) {
this.applicable = applicable;
this.global = global;
@ -256,6 +252,12 @@ private ProtectedRegion getAffectedRegion() {
}
public boolean isAnyRegionAffected()
{
return this.applicable.size() > 0;
}
/**
* Determines the region with the hightest priority that is not a parent.
*

View File

@ -15,8 +15,7 @@
*
* 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.regionmanager;
import java.io.IOException;
@ -31,8 +30,6 @@
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.protection.UnsupportedIntersectionException;
import com.sk89q.worldguard.protection.dbs.ProtectionDatabase;
import java.util.HashMap;
/**
* A very simple implementation of the region manager that uses a flat list
@ -42,40 +39,40 @@
* @author sk89q
*/
public class FlatRegionManager extends RegionManager {
/**
* List of protected regions.
*/
private Map<String,ProtectedRegion> regions;
private Map<String, ProtectedRegion> regions;
/**
* Construct the manager.
*/
public FlatRegionManager(GlobalFlags global, ProtectionDatabase regionloader) throws IOException {
super(global, regionloader);
regions = new TreeMap<String,ProtectedRegion>();
this.load();
super(global, regionloader);
regions = new TreeMap<String, ProtectedRegion>();
this.load();
}
/**
* Get a list of protected regions.
*
* @return
*/
public Map<String,ProtectedRegion> getRegions() {
public Map<String, ProtectedRegion> getRegions() {
return regions;
}
/**
* Set a list of protected regions.
*
* @return
*/
public void setRegions(Map<String,ProtectedRegion> regions) {
this.regions = new TreeMap<String,ProtectedRegion>(regions);
public void setRegions(Map<String, ProtectedRegion> regions) {
this.regions = new TreeMap<String, ProtectedRegion>(regions);
}
/**
* Adds a region.
*
@ -85,7 +82,7 @@ public void setRegions(Map<String,ProtectedRegion> regions) {
public void addRegion(ProtectedRegion region) {
regions.put(region.getId(), region);
}
/**
* Removes a region and its children.
*
@ -93,9 +90,9 @@ public void addRegion(ProtectedRegion region) {
*/
public void removeRegion(String id) {
ProtectedRegion region = regions.get(id);
regions.remove(id);
if (region != null) {
for (Map.Entry<String, ProtectedRegion> entry : regions.entrySet()) {
if (entry.getValue().getParent() == region) {
@ -104,7 +101,7 @@ public void removeRegion(String id) {
}
}
}
/**
* Return whether a region exists by an ID.
*
@ -114,7 +111,7 @@ public void removeRegion(String id) {
public boolean hasRegion(String id) {
return regions.containsKey(id);
}
/**
* Get a region by its ID.
*
@ -123,7 +120,7 @@ public boolean hasRegion(String id) {
public ProtectedRegion getRegion(String id) {
return regions.get(id);
}
/**
* Get an object for a point for rules to be applied with.
*
@ -132,18 +129,39 @@ public ProtectedRegion getRegion(String id) {
*/
public ApplicableRegionSet getApplicableRegions(Vector pt) {
List<ProtectedRegion> appRegions = new ArrayList<ProtectedRegion>();
for (ProtectedRegion region : regions.values()) {
if (region.contains(pt)) {
appRegions.add(region);
}
}
return new ApplicableRegionSet(appRegions, global);
}
/**
* Get an object for a region for rules to be applied with.
*
* @param pt
* @return
*/
public ApplicableRegionSet getApplicableRegions(ProtectedRegion checkRegion) {
List<ProtectedRegion> appRegions = new ArrayList<ProtectedRegion>();
for (Map.Entry<String,ProtectedRegion> entry : regions.entrySet()) {
if (entry.getValue().contains(pt)) {
appRegions.add(entry.getValue());
for (ProtectedRegion region : regions.values()) {
try {
if (region.intersectsWith(checkRegion)) {
appRegions.add(region);
}
} catch (UnsupportedIntersectionException ex) {
}
}
return new ApplicableRegionSet(pt, appRegions, global);
return new ApplicableRegionSet(appRegions, global);
}
/**
* Get a list of region IDs that contain a point.
*
@ -152,16 +170,16 @@ public ApplicableRegionSet getApplicableRegions(Vector pt) {
*/
public List<String> getApplicableRegionsIDs(Vector pt) {
List<String> applicable = new ArrayList<String>();
for (Map.Entry<String,ProtectedRegion> entry : regions.entrySet()) {
for (Map.Entry<String, ProtectedRegion> entry : regions.entrySet()) {
if (entry.getValue().contains(pt)) {
applicable.add(entry.getKey());
}
}
return applicable;
}
/**
* Returns true if the provided region overlaps with any other region that
* is not owned by the player.
@ -175,19 +193,19 @@ public boolean overlapsUnownedRegion(ProtectedRegion region, LocalPlayer player)
if (other.getOwners().contains(player)) {
continue;
}
try {
if (ProtectedRegion.intersects(region, other)) {
if (region.intersectsWith(other)) {
return true;
}
} catch (UnsupportedIntersectionException e) {
// TODO: Maybe do something here
}
}
return false;
}
/**
* Get the number of regions.
*
@ -197,20 +215,28 @@ public int size() {
return regions.size();
}
/**
* Save the list of regions.
*
* @throws IOException
*/
public void save() throws IOException
{
if(this.regionloader == null)
{
public void save() throws IOException {
if (this.regionloader == null) {
return;
}
regionloader.save(this);
}
public int getRegionCountOfPlayer(LocalPlayer player) {
int count = 0;
for (ProtectedRegion region : regions.values()) {
if (region.getOwners().contains(player)) {
count++;
}
}
return count;
}
}

View File

@ -15,8 +15,7 @@
*
* 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.regionmanager;
import java.util.ArrayList;
@ -34,22 +33,18 @@
import com.sk89q.worldguard.protection.UnsupportedIntersectionException;
import com.sk89q.worldguard.protection.dbs.ProtectionDatabase;
import java.io.IOException;
import java.util.HashMap;
public class PRTreeRegionManager extends RegionManager {
private static final int BRANCH_FACTOR = 30;
private static final int BRANCH_FACTOR = 30;
/**
* List of protected regions.
*/
private Map<String,ProtectedRegion> regions;
private Map<String, ProtectedRegion> regions;
/**
* Converter to get coordinates of the tree.
*/
private MBRConverter<ProtectedRegion> converter
= new ProtectedRegionMBRConverter();
private MBRConverter<ProtectedRegion> converter = new ProtectedRegionMBRConverter();
/**
* Priority R-tree.
*/
@ -60,27 +55,27 @@ public class PRTreeRegionManager extends RegionManager {
*/
public PRTreeRegionManager(GlobalFlags global, ProtectionDatabase regionloader) throws IOException {
super(global, regionloader);
regions = new TreeMap<String,ProtectedRegion>();
regions = new TreeMap<String, ProtectedRegion>();
tree = new PRTree<ProtectedRegion>(converter, BRANCH_FACTOR);
this.load();
}
/**
* Get a list of protected regions.
*
* @return
*/
public Map<String,ProtectedRegion> getRegions() {
public Map<String, ProtectedRegion> getRegions() {
return regions;
}
/**
* Set a list of protected regions.
*
* @return
*/
public void setRegions(Map<String,ProtectedRegion> regions) {
this.regions = new TreeMap<String,ProtectedRegion>(regions);
public void setRegions(Map<String, ProtectedRegion> regions) {
this.regions = new TreeMap<String, ProtectedRegion>(regions);
tree = new PRTree<ProtectedRegion>(converter, BRANCH_FACTOR);
tree.load(regions.values());
}
@ -115,7 +110,7 @@ public boolean hasRegion(String id) {
public ProtectedRegion getRegion(String id) {
return regions.get(id);
}
/**
* Removes a region and its children.
*
@ -123,9 +118,9 @@ public ProtectedRegion getRegion(String id) {
*/
public void removeRegion(String id) {
ProtectedRegion region = regions.get(id);
regions.remove(id);
if (region != null) {
for (Map.Entry<String, ProtectedRegion> entry : regions.entrySet()) {
if (entry.getValue().getParent() == region) {
@ -157,7 +152,22 @@ public ApplicableRegionSet getApplicableRegions(Vector pt) {
}
}
return new ApplicableRegionSet(pt, appRegions, global);
return new ApplicableRegionSet(appRegions, global);
}
public ApplicableRegionSet getApplicableRegions(ProtectedRegion checkRegion) {
List<ProtectedRegion> appRegions = new ArrayList<ProtectedRegion>();
for (ProtectedRegion region : regions.values()) {
try {
if (region.intersectsWith(checkRegion)) {
appRegions.add(region);
}
} catch (UnsupportedIntersectionException ex) {
}
}
return new ApplicableRegionSet(appRegions, global);
}
/**
@ -171,16 +181,16 @@ public List<String> getApplicableRegionsIDs(Vector pt) {
int x = pt.getBlockX();
int z = pt.getBlockZ();
for (ProtectedRegion region : tree.find(x, z, x, z)) {
if (region.contains(pt)) {
applicable.add(region.getId());
}
}
return applicable;
}
/**
* Returns true if the provided region overlaps with any other region that
* is not owned by the player.
@ -194,19 +204,19 @@ public boolean overlapsUnownedRegion(ProtectedRegion region, LocalPlayer player)
if (other.getOwners().contains(player)) {
continue;
}
try {
if (ProtectedRegion.intersects(region, other)) {
if (region.intersectsWith(other)) {
return true;
}
} catch (UnsupportedIntersectionException e) {
// TODO: Maybe do something here
}
}
return false;
}
/**
* Get the number of regions.
*
@ -221,9 +231,19 @@ public int size() {
*
* @throws IOException
*/
public void save() throws IOException
{
public void save() throws IOException {
regionloader.save(this);
}
public int getRegionCountOfPlayer(LocalPlayer player) {
int count = 0;
for (Map.Entry<String, ProtectedRegion> entry : regions.entrySet()) {
if (entry.getValue().getOwners().contains(player)) {
count++;
}
}
return count;
}
}

View File

@ -142,7 +142,17 @@ public void load() throws IOException
* @return
*/
public abstract ApplicableRegionSet getApplicableRegions(Vector pt);
/**
* Get an object for a point for rules to be applied with.
*
* @param pt
* @return
*/
public abstract ApplicableRegionSet getApplicableRegions(ProtectedRegion region);
/**
* Get a list of region IDs that contain a point.
*
@ -177,4 +187,7 @@ public void setGlobalFlags(GlobalFlags globalflags)
{
global = globalflags;
}
public abstract int getRegionCountOfPlayer(LocalPlayer player);
}

View File

@ -15,11 +15,11 @@
*
* 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.regions;
import com.sk89q.worldedit.*;
import com.sk89q.worldguard.protection.UnsupportedIntersectionException;
/**
* Represents a cuboid region that can be protected.
@ -27,6 +27,7 @@
* @author sk89q
*/
public class ProtectedCuboidRegion extends ProtectedRegion {
/**
* Store the first point.
*/
@ -98,7 +99,37 @@ public boolean contains(Vector pt) {
&& y >= min.getBlockY() && y <= max.getBlockY()
&& 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) {
ProtectedCuboidRegion r1 = (ProtectedCuboidRegion) this;
ProtectedCuboidRegion r2 = (ProtectedCuboidRegion) region;
BlockVector min1 = r1.getMinimumPoint();
BlockVector max1 = r1.getMaximumPoint();
BlockVector min2 = r2.getMinimumPoint();
BlockVector max2 = r2.getMaximumPoint();
return !(min1.getBlockX() > max2.getBlockX()
|| min1.getBlockY() > max2.getBlockY()
|| min1.getBlockZ() > max2.getBlockZ()
|| max1.getBlockX() < min2.getBlockX()
|| max1.getBlockY() < min2.getBlockY()
|| max1.getBlockZ() < min2.getBlockZ());
} else if (region instanceof ProtectedPolygonalRegion) {
throw new UnsupportedIntersectionException();
} else {
throw new UnsupportedIntersectionException();
}
}
/**
* Return the type of region as a user-friendly name.
*

View File

@ -15,41 +15,49 @@
*
* 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.regions;
import java.util.List;
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.BlockVector2D;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldguard.protection.UnsupportedIntersectionException;
public class ProtectedPolygonalRegion extends ProtectedRegion {
protected List<BlockVector2D> points;
protected int minY;
protected int maxY;
private BlockVector min;
private BlockVector max;
public ProtectedPolygonalRegion(String id, List<BlockVector2D> points, int minY, int maxY) {
super(id);
this.points = points;
this.minY = minY;
this.maxY = maxY;
int minX = points.get(0).getBlockX();
int minZ = points.get(0).getBlockZ();
int maxX = points.get(0).getBlockX();
int maxZ = points.get(0).getBlockZ();
for (BlockVector2D v : points) {
int x = v.getBlockX();
int z = v.getBlockZ();
if (x < minX) minX = x;
if (z < minZ) minZ = z;
if (x > maxX) maxX = x;
if (z > maxZ) maxZ = z;
if (x < minX) {
minX = x;
}
if (z < minZ) {
minZ = z;
}
if (x > maxX) {
maxX = x;
}
if (z > maxZ) {
maxZ = z;
}
}
min = new BlockVector(minX, minY, minZ);
@ -74,13 +82,13 @@ public boolean contains(Vector pt) {
int targetX = pt.getBlockX(); //wide
int targetY = pt.getBlockY(); //height
int targetZ = pt.getBlockZ(); //depth
if (targetY < minY || targetY > maxY) {
return false;
}
//Quick and dirty check.
if(targetX < min.getBlockX() || targetX > max.getBlockX() || targetZ < min.getBlockZ() || targetZ > max.getBlockZ()){
return false;
if (targetX < min.getBlockX() || targetX > max.getBlockX() || targetZ < min.getBlockZ() || targetZ > max.getBlockZ()) {
return false;
}
boolean inside = false;
int npoints = points.size();
@ -92,13 +100,13 @@ public boolean contains(Vector pt) {
xOld = points.get(npoints - 1).getBlockX();
zOld = points.get(npoints - 1).getBlockZ();
for (i = 0; i < npoints; i++) {
xNew = points.get(i).getBlockX();
zNew = points.get(i).getBlockZ();
//Check for corner
if(xNew == targetX && zNew == targetZ){
return true;
if (xNew == targetX && zNew == targetZ) {
return true;
}
if (xNew > xOld) {
x1 = xOld;
@ -113,16 +121,34 @@ public boolean contains(Vector pt) {
}
if ((xNew < targetX) == (targetX <= xOld)
&& ((long) targetZ - (long) z1) * (long) (x2 - x1) <= ((long) z2 - (long) z1)
* (long) (targetX - x1)) {
* (long) (targetX - x1)) {
inside = !inside;
}
xOld = xNew;
zOld = zNew;
}
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();
}
}
/**
* Return the type of region as a user-friendly name.
*
@ -141,7 +167,7 @@ public String getTypeName() {
public int countBlocks() {
int volume = 0;
int numPoints = points.size();
if(numPoints < 3) {
if (numPoints < 3) {
return 0;
}
@ -152,12 +178,12 @@ public int countBlocks() {
xa = points.get(i).getBlockX();
za = points.get(i).getBlockZ();
if (points.get(i + 1) == null ) {
if (points.get(i + 1) == null) {
z1 = points.get(0).getBlockZ();
} else {
z1 = points.get(i + 1).getBlockZ();
}
if (points.get(i - 1) == null ) {
if (points.get(i - 1) == null) {
z2 = points.get(numPoints - 1).getBlockZ();
} else {
z2 = points.get(i - 1).getBlockZ();
@ -171,7 +197,7 @@ public int countBlocks() {
area = area + (xa * (points.get(1).getBlockZ() - points.get(numPoints - 1).getBlockZ()));
volume = (Math.abs(maxY - minY) + 1) * (int)Math.ceil((Math.abs(area) / 2));
volume = (Math.abs(maxY - minY) + 1) * (int) Math.ceil((Math.abs(area) / 2));
return volume;
}

View File

@ -225,7 +225,8 @@ public boolean isOwner(LocalPlayer player) {
return false;
}
/**
* Checks whether a player is a member of the region or any of its parents.
*
@ -300,32 +301,12 @@ public int compareTo(ProtectedRegion other) {
/**
* Checks if two region intersects.
*
* @param region1
* @param region2
* @param region
* @throws UnsupportedIntersectionException
* @return
*/
public static boolean intersects(ProtectedRegion region1, ProtectedRegion region2)
throws UnsupportedIntersectionException {
if (region1 instanceof ProtectedCuboidRegion
&& region2 instanceof ProtectedCuboidRegion) {
ProtectedCuboidRegion r1 = (ProtectedCuboidRegion)region1;
ProtectedCuboidRegion r2 = (ProtectedCuboidRegion)region2;
BlockVector min1 = r1.getMinimumPoint();
BlockVector max1 = r1.getMaximumPoint();
BlockVector min2 = r2.getMinimumPoint();
BlockVector max2 = r2.getMaximumPoint();
return !(min1.getBlockX() > max2.getBlockX()
|| min1.getBlockY() > max2.getBlockY()
|| min1.getBlockZ() > max2.getBlockZ()
|| max1.getBlockX() < min2.getBlockX()
|| max1.getBlockY() < min2.getBlockY()
|| max1.getBlockZ() < min2.getBlockZ());
} else {
throw new UnsupportedIntersectionException();
}
}
public abstract boolean intersectsWith(ProtectedRegion region) throws UnsupportedIntersectionException;
/**
* Thrown when setting a parent would create a circular inheritance