Package redempt.redlib.region
Class Region
java.lang.Object
redempt.redlib.region.Region
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
Overlappable
,SpheroidRegion
Represents a region of an unspecified shape in the world
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract Region
clone()
boolean
contains
(org.bukkit.block.Block block) Checks whether a Block is contained by this Regionabstract boolean
contains
(org.bukkit.Location loc) Determines if this Region contains a Locationvoid
Disable RegionEnterEvent and RegionExitEvent for this regionvoid
Enable RegionEnterEvent and RegionExitEvent for this regionboolean
Determines whether this Region equals another Object based ongetStart()
andgetEnd()
abstract Region
expand
(double posX, double negX, double posY, double negY, double posZ, double negZ) Expands this Region by a specified amount in each directionabstract Region
expand
(org.bukkit.block.BlockFace face, double amount) Expands this Region in a specific directionvoid
forEachBlock
(Consumer<org.bukkit.block.Block> forEach) Streams every Block in this Region, running your lambda on itint[]
Get the dimensions of this Region [x, y, z] in blocksabstract int
org.bukkit.Location
Set<org.bukkit.Chunk>
org.bukkit.Location[]
double[]
Get the dimensions of this Region [x, y, z]abstract org.bukkit.Location
getEnd()
List<org.bukkit.entity.Entity>
Gets all entities contained in this Region in loaded chunksList<org.bukkit.entity.Entity>
getEntities
(boolean load) Gets all entities contained in this RegionSet<org.bukkit.Chunk>
List<org.bukkit.entity.Player>
Gets all players contained in this Regionabstract org.bukkit.Location
getStart()
abstract double
org.bukkit.World
getWorld()
int
hashCode()
Generates a hash code based ongetStart()
andgetEnd()
double
measure
(org.bukkit.block.BlockFace direction) Gets the length of this Region along a given axisint
measureBlocks
(org.bukkit.block.BlockFace direction) Gets the block length of this Region along a given axisabstract Region
move
(double x, double y, double z) abstract Region
move
(org.bukkit.util.Vector vec) Moves this Regionprotect
(org.bukkit.plugin.Plugin plugin, ProtectionPolicy.ProtectionType... types) Protects this Regionprotect
(ProtectionPolicy.ProtectionType... types) Protects this Regionabstract Region
rotate
(org.bukkit.Location center, int rotations) Rotates this Region around a central pointabstract Region
setWorld
(org.bukkit.World world) Sets the World of this Regionabstract Stream<org.bukkit.block.Block>
stream()
Streams all Blocks inside this RegiontoCuboid()
-
Constructor Details
-
Region
public Region()
-
-
Method Details
-
getStart
public abstract org.bukkit.Location getStart()- Returns:
- The least extreme corner of this Region
-
getEnd
public abstract org.bukkit.Location getEnd()- Returns:
- The most extreme corner of this Region
-
getVolume
public abstract double getVolume()- Returns:
- The volume of this Region, in cubic meters
-
getBlockVolume
public abstract int getBlockVolume()- Returns:
- The volume of this Region, in whole blocks
-
expand
public abstract Region expand(double posX, double negX, double posY, double negY, double posZ, double negZ) Expands this Region by a specified amount in each direction- Parameters:
posX
- The amount to increase in the positive X directionnegX
- The amount to increase in the negative X directionposY
- The amount to increase in the positive Y directionnegY
- The amount to increase in the negative Y directionposZ
- The amount to increase in the positive Z directionnegZ
- The amount to increase in the negative Z direction- Returns:
- Itself
-
expand
Expands this Region in a specific direction- Parameters:
face
- The BlockFace representing the direction to expand inamount
- The amount to expand- Returns:
- Itself
-
move
Moves this Region- Parameters:
vec
- The vector representing the direction and amount to move- Returns:
- Itself
-
move
-
contains
public abstract boolean contains(org.bukkit.Location loc) Determines if this Region contains a Location- Parameters:
loc
- The location to check- Returns:
- Whether the location is contained by this Region
-
clone
-
rotate
Rotates this Region around a central point- Parameters:
center
- The center of rotationrotations
- The number of clockwise rotations- Returns:
- Itself
-
setWorld
Sets the World of this Region- Parameters:
world
- The World- Returns:
- Itself
-
stream
Streams all Blocks inside this Region- Returns:
- The stream of all Blocks contained in this Region
-
getChunks
- Returns:
- All the Chunks this Region overlaps
-
contains
public boolean contains(org.bukkit.block.Block block) Checks whether a Block is contained by this Region- Parameters:
block
- The Block- Returns:
- Whether the Block is contained by this Region
-
getLoadedChunks
- Returns:
- All the loaded Chunks this Region overlaps
-
enableEvents
public void enableEvents()Enable RegionEnterEvent and RegionExitEvent for this region -
disableEvents
public void disableEvents()Disable RegionEnterEvent and RegionExitEvent for this region -
getPlayers
Gets all players contained in this Region- Returns:
- The players in this Region
-
getEntities
Gets all entities contained in this Region in loaded chunks- Returns:
- The entities in this Region
-
getEntities
Gets all entities contained in this Region- Parameters:
load
- Whether to load chunks to check the entities inside them- Returns:
- The entities in this Region
-
getWorld
public org.bukkit.World getWorld()- Returns:
- The World this Region is in
-
forEachBlock
Streams every Block in this Region, running your lambda on it- Parameters:
forEach
- What to run on each Block
-
getBlockDimensions
public int[] getBlockDimensions()Get the dimensions of this Region [x, y, z] in blocks- Returns:
- The dimensions of this Region
-
getDimensions
public double[] getDimensions()Get the dimensions of this Region [x, y, z]- Returns:
- The dimensions of this Region
-
getCorners
public org.bukkit.Location[] getCorners()- Returns:
- All 8 cuboid corners of this Region
-
toCuboid
- Returns:
- A cuboid representation of this Region using the extreme corners
-
getCenter
public org.bukkit.Location getCenter()- Returns:
- The center of this Region, the midpoint of the two extreme corners
-
protect
public ProtectedRegion protect(org.bukkit.plugin.Plugin plugin, ProtectionPolicy.ProtectionType... types) Protects this Region- Parameters:
plugin
- The plugin registering the protectiontypes
- The ProtectionTypes to protect this Region with- Returns:
- The ProtectedRegion using this Region and the given ProtectionTypes
-
protect
Protects this Region- Parameters:
types
- The ProtectionTypes to protect this Region with- Returns:
- The ProtectedRegion using this Region and the given ProtectionTypes
-
measure
public double measure(org.bukkit.block.BlockFace direction) Gets the length of this Region along a given axis- Parameters:
direction
- The BlockFace representing the axis - opposites will act the same (i.e. UP, DOWN)- Returns:
- The length of this Region along the given axis
-
measureBlocks
public int measureBlocks(org.bukkit.block.BlockFace direction) Gets the block length of this Region along a given axis- Parameters:
direction
- The BlockFace representing the axis - opposites will act the same (i.e. UP, DOWN)- Returns:
- The block length of this Region along the given axis
-
equals
Determines whether this Region equals another Object based ongetStart()
andgetEnd()
-
hashCode
public int hashCode()Generates a hash code based ongetStart()
andgetEnd()
-