Class Region

java.lang.Object
redempt.redlib.region.Region
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
Overlappable, SpheroidRegion

public abstract class Region extends Object implements Cloneable
Represents a region of an unspecified shape in the world
  • 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 direction
      negX - The amount to increase in the negative X direction
      posY - The amount to increase in the positive Y direction
      negY - The amount to increase in the negative Y direction
      posZ - The amount to increase in the positive Z direction
      negZ - The amount to increase in the negative Z direction
      Returns:
      Itself
    • expand

      public abstract Region expand(org.bukkit.block.BlockFace face, double amount)
      Expands this Region in a specific direction
      Parameters:
      face - The BlockFace representing the direction to expand in
      amount - The amount to expand
      Returns:
      Itself
    • move

      public abstract Region move(org.bukkit.util.Vector vec)
      Moves this Region
      Parameters:
      vec - The vector representing the direction and amount to move
      Returns:
      Itself
    • move

      public abstract Region move(double x, double y, double z)
    • 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

      public abstract Region clone()
      Overrides:
      clone in class Object
      Returns:
      A clone of this Region
    • rotate

      public abstract Region rotate(org.bukkit.Location center, int rotations)
      Rotates this Region around a central point
      Parameters:
      center - The center of rotation
      rotations - The number of clockwise rotations
      Returns:
      Itself
    • setWorld

      public abstract Region setWorld(org.bukkit.World world)
      Sets the World of this Region
      Parameters:
      world - The World
      Returns:
      Itself
    • stream

      public abstract Stream<org.bukkit.block.Block> stream()
      Streams all Blocks inside this Region
      Returns:
      The stream of all Blocks contained in this Region
    • getChunks

      public Set<org.bukkit.Chunk> 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

      public Set<org.bukkit.Chunk> 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

      public List<org.bukkit.entity.Player> getPlayers()
      Gets all players contained in this Region
      Returns:
      The players in this Region
    • getEntities

      public List<org.bukkit.entity.Entity> getEntities()
      Gets all entities contained in this Region in loaded chunks
      Returns:
      The entities in this Region
    • getEntities

      public List<org.bukkit.entity.Entity> getEntities(boolean load)
      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

      public void forEachBlock(Consumer<org.bukkit.block.Block> forEach)
      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

      public CuboidRegion 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 protection
      types - 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

      public boolean equals(Object object)
      Determines whether this Region equals another Object based on getStart() and getEnd()
      Overrides:
      equals in class Object
      Parameters:
      object - The Object to compare to
      Returns:
      Whether the Object is equal to this Region
    • hashCode

      public int hashCode()
      Generates a hash code based on getStart() and getEnd()
      Overrides:
      hashCode in class Object
      Returns:
      The hash code