/** * Set the minimum and maximum points of the bounding box for a region * * @param points the points to set with at least one entry */ protected void setMinMaxPoints(List<Vector> points) { int minX = points.get(0).getBlockX(); int minY = points.get(0).getBlockY(); int minZ = points.get(0).getBlockZ(); int maxX = minX; int maxY = minY; int maxZ = minZ; for (Vector v : points) { int x = v.getBlockX(); int y = v.getBlockY(); int z = v.getBlockZ(); if (x < minX) minX = x; if (y < minY) minY = y; if (z < minZ) minZ = z; if (x > maxX) maxX = x; if (y > maxY) maxY = y; if (z > maxZ) maxZ = z; } setDirty(true); min = new BlockVector(minX, minY, minZ); max = new BlockVector(maxX, maxY, maxZ); }
/** * Set a flag's value. * * @param flag the flag to check * @param val the value to set * @param <T> the flag type * @param <V> the type of the flag's value */ public <T extends Flag<V>, V> void setFlag(T flag, @Nullable V val) { checkNotNull(flag); setDirty(true); if (val == null) { flags.remove(flag); } else { flags.put(flag, val); } }
/** * Set the parent of this region. This checks to make sure that it will not result in circular * inheritance. * * @param parent the new parent * @throws CircularInheritanceException when circular inheritance is detected */ public void setParent(@Nullable ProtectedRegion parent) throws CircularInheritanceException { setDirty(true); if (parent == null) { this.parent = null; return; } if (parent == this) { throw new CircularInheritanceException(); } ProtectedRegion p = parent.getParent(); while (p != null) { if (p == this) { throw new CircularInheritanceException(); } p = p.getParent(); } this.parent = parent; }
/** * Set the map of flags. * * <p>A copy of the map will be used. * * @param flags the flags to set */ public void setFlags(Map<Flag<?>, Object> flags) { checkNotNull(flags); setDirty(true); this.flags = new ConcurrentHashMap<Flag<?>, Object>(flags); }
/** * Set the members domain. * * @param members the new domain */ public void setMembers(DefaultDomain members) { checkNotNull(members); setDirty(true); this.members = new DefaultDomain(members); }
/** * Set the owner domain. * * @param owners the new domain */ public void setOwners(DefaultDomain owners) { checkNotNull(owners); setDirty(true); this.owners = new DefaultDomain(owners); }
/** Clear the parent (set the parent to {@code null}). */ public void clearParent() { setDirty(true); this.parent = null; }
/** * Set the priority of the region, where higher numbers indicate a higher priority. * * @param priority the priority to set */ public void setPriority(int priority) { setDirty(true); this.priority = priority; }