Interface IQueueExtent<T extends IChunk>

All Superinterfaces:
Extent, Flushable, IBatchProcessor, IBatchProcessorHolder, IChunkExtent<T>, InputExtent, OutputExtent, Trimable
All Known Implementing Classes:
SingleThreadQueueExtent

public interface IQueueExtent<T extends IChunk> extends Flushable, Trimable, IChunkExtent<T>, IBatchProcessorHolder
TODO: implement Extent (need to refactor Extent first) Interface for a queue based extent which uses chunks
  • Method Details

    • isQueueEnabled

      default boolean isQueueEnabled()
      Specified by:
      isQueueEnabled in interface Extent
    • enableQueue

      void enableQueue()
      Must ensure that it is enqueued with QueueHandler
      Specified by:
      enableQueue in interface Extent
    • disableQueue

      void disableQueue()
      Must ensure it is not in the queue handler (i.e. does not change blocks in the world)
      Specified by:
      disableQueue in interface Extent
    • init

      void init(Extent extent, IChunkCache<IChunkGet> get, IChunkCache<IChunkSet> set)
      Initialize the queue (for reusability)
      Parameters:
      extent - extent to use
      get - cache of chunk GET
      set - cache of chunk SET
    • getCachedGet

      IChunkGet getCachedGet(int chunkX, int chunkZ)
      Get the cached get object. This is faster than getting the object using NMS and allows for wrapping.
    • getCachedSet

      IChunkSet getCachedSet(int chunkX, int chunkZ)
      Get the cached chunk set object.
    • submit

      <V extends Future<V>> V submit(T chunk)
      Submit the chunk so that it's changes are applied to the world
      Returns:
      Future
    • getMinimumPoint

      default BlockVector3 getMinimumPoint()
      Description copied from interface: Extent
      Get the minimum point in the extent.

      If the extent is unbounded, then a large (negative) value may be returned.

      Specified by:
      getMinimumPoint in interface Extent
      Returns:
      the minimum point
    • getMaximumPoint

      default BlockVector3 getMaximumPoint()
      Description copied from interface: Extent
      Get the maximum point in the extent.

      If the extent is unbounded, then a large (positive) value may be returned.

      Specified by:
      getMaximumPoint in interface Extent
      Returns:
      the maximum point
    • setFastMode

      void setFastMode(boolean fastMode)
    • isFastMode

      boolean isFastMode()
    • create

      T create(boolean isFull)
      Create a new root IChunk object. Full chunks will be reused, so a more optimized chunk can be returned in that case.
      Parameters:
      isFull - true if a more optimized chunk should be returned
      Returns:
      a more optimized chunk object
      See Also:
    • wrap

      default T wrap(T root)
      Wrap the chunk object (i.e., for region restrictions / limits etc.).
      Returns:
      wrapped chunk
    • commit

      @Nullable default Operation commit()
      Description copied from interface: OutputExtent
      Return an Operation that should be called to tie up loose ends (such as to commit changes in a buffer).
      Specified by:
      commit in interface Extent
      Specified by:
      commit in interface OutputExtent
      Returns:
      an operation or null if there is none to execute
    • flush

      void flush()
      Flush all changes to the world. Best to call this async, so it doesn't hang the server.
      Specified by:
      flush in interface Flushable
      Specified by:
      flush in interface IBatchProcessor
    • createFilterBlock

      ChunkFilterBlock createFilterBlock()
      A filter block is used to iterate over blocks / positions. Essentially combines BlockVector3, Extent and BlockState functions in a way that avoids lookups.
    • size

      int size()
      Returns the number of chunks in this queue.
      Returns:
      the number of chunks in this queue
    • isEmpty

      boolean isEmpty()
      Returns:
      true if this queue contains no elements
    • apply

      default ChunkFilterBlock apply(@Nullable ChunkFilterBlock block, Filter filter, Region region, int chunkX, int chunkZ, boolean full)
    • apply

      default <T extends Filter> T apply(Region region, T filter, boolean full)
      Specified by:
      apply in interface Extent