Interface RegionIndex

All Superinterfaces:
ChangeTracked
All Known Subinterfaces:
ConcurrentRegionIndex
All Known Implementing Classes:
ChunkHashTable, HashMapIndex, PriorityRTreeIndex

public interface RegionIndex extends ChangeTracked
An index of regions to allow for fast lookups of regions by their ID and through spatial queries.

Indexes may be thread-unsafe.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Add a region to this index, replacing any existing one with the same name (equality determined using Normal).
    void
    Add a list of regions to this index, replacing any existing one with the same name (equality determined using Normal).
    void
    Apply the given predicate to all the regions in the index until there are no more regions or the predicate returns false.
    void
    applyContaining(com.sk89q.worldedit.math.BlockVector3 position, Predicate<ProtectedRegion> consumer)
    Apply the given predicate to all regions that contain the given position until there are no more regions or the predicate returns false.
    void
    Apply the given predicate to all regions that intersect the given region until there are no more regions or the predicate returns false.
    void
    bias(com.sk89q.worldedit.math.BlockVector2 chunkPosition)
    Bias the given chunk for faster lookups (put it in a hash table, etc.).
    void
    biasAll(Collection<com.sk89q.worldedit.math.BlockVector2> chunkPosition)
    Bias the given chunk for faster lookups (put it in a hash table, etc.).
    boolean
    Test whether the index contains a region named by the given name (equality determined using Normal).
    void
    forget(com.sk89q.worldedit.math.BlockVector2 chunkPosition)
    No longer bias the given chunk for faster lookup.
    void
    Clearly all extra cache data created by any calls to bias(BlockVector2).
    get(String id)
    Get the region named by the given name (equality determined using Normal).
    Get the list of changed or removed regions since last call and clear those lists.
    remove(String id, RemovalStrategy strategy)
    Remove a region from the index with the given name.
    void
    Set the index to be dirty using the given difference.
    int
    Return the number of regions in the index.
    Get an unmodifiable collection of regions stored in this index.

    Methods inherited from interface com.sk89q.worldguard.util.ChangeTracked

    isDirty, setDirty
  • Method Details

    • bias

      void bias(com.sk89q.worldedit.math.BlockVector2 chunkPosition)
      Bias the given chunk for faster lookups (put it in a hash table, etc.).

      Implementations may choose to do nothing.

      Parameters:
      chunkPosition - the chunk position
    • biasAll

      void biasAll(Collection<com.sk89q.worldedit.math.BlockVector2> chunkPosition)
      Bias the given chunk for faster lookups (put it in a hash table, etc.).

      Implementations may choose to do nothing.

      Parameters:
      chunkPosition - the chunk position
    • forget

      void forget(com.sk89q.worldedit.math.BlockVector2 chunkPosition)
      No longer bias the given chunk for faster lookup.
      Parameters:
      chunkPosition - the chunk position
    • forgetAll

      void forgetAll()
      Clearly all extra cache data created by any calls to bias(BlockVector2).
    • add

      void add(ProtectedRegion region)
      Add a region to this index, replacing any existing one with the same name (equality determined using Normal).

      The parents of the region will also be added to the index.

      Parameters:
      region - the region
    • addAll

      void addAll(Collection<ProtectedRegion> regions)
      Add a list of regions to this index, replacing any existing one with the same name (equality determined using Normal).

      The parents of the region will also be added to the index.

      Parameters:
      regions - a collections of regions
    • remove

      Set<ProtectedRegion> remove(String id, RemovalStrategy strategy)
      Remove a region from the index with the given name.
      Parameters:
      id - the name of the region
      strategy - what to do with children
      Returns:
      a list of removed regions where the first entry is the region specified by id
    • contains

      boolean contains(String id)
      Test whether the index contains a region named by the given name (equality determined using Normal).
      Parameters:
      id - the name of the region
      Returns:
      true if the index contains the region
    • get

      @Nullable ProtectedRegion get(String id)
      Get the region named by the given name (equality determined using Normal).
      Parameters:
      id - the name of the region
      Returns:
      a region or null
    • apply

      void apply(Predicate<ProtectedRegion> consumer)
      Apply the given predicate to all the regions in the index until there are no more regions or the predicate returns false.
      Parameters:
      consumer - a predicate that returns true to continue iterating
    • applyContaining

      void applyContaining(com.sk89q.worldedit.math.BlockVector3 position, Predicate<ProtectedRegion> consumer)
      Apply the given predicate to all regions that contain the given position until there are no more regions or the predicate returns false.
      Parameters:
      position - the position
      consumer - a predicate that returns true to continue iterating
    • applyIntersecting

      void applyIntersecting(ProtectedRegion region, Predicate<ProtectedRegion> consumer)
      Apply the given predicate to all regions that intersect the given region until there are no more regions or the predicate returns false.
      Parameters:
      region - the intersecting region
      consumer - a predicate that returns true to continue iterating
    • size

      int size()
      Return the number of regions in the index.
      Returns:
      the number of regions
    • getAndClearDifference

      RegionDifference getAndClearDifference()
      Get the list of changed or removed regions since last call and clear those lists.
      Returns:
      the difference
    • setDirty

      void setDirty(RegionDifference difference)
      Set the index to be dirty using the given difference.
      Parameters:
      difference - the difference
    • values

      Get an unmodifiable collection of regions stored in this index.
      Returns:
      a collection of regions