Class SingleThreadQueueExtent

All Implemented Interfaces:
IBatchProcessorHolder, IBatchProcessor, IChunkExtent<IQueueChunk>, IQueueExtent<IQueueChunk>, Trimable, Extent, InputExtent, OutputExtent, Flushable

public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implements IQueueExtent<IQueueChunk>
Single threaded implementation for IQueueExtent (still abstract) - Does not implement creation of chunks (that has to implemented by the platform e.g., Bukkit)

This queue is reusable init(Extent, IChunkCache, IChunkCache)

  • Constructor Details

    • SingleThreadQueueExtent

      public SingleThreadQueueExtent()
    • SingleThreadQueueExtent

      public SingleThreadQueueExtent(int minY, int maxY)
      New instance given inclusive world height bounds.
  • Method Details

    • enableQueue

      public void enableQueue()
      Description copied from interface: IQueueExtent
      Must ensure that it is enqueued with QueueHandler
      Specified by:
      enableQueue in interface Extent
      Specified by:
      enableQueue in interface IQueueExtent<IQueueChunk>
    • disableQueue

      public void disableQueue()
      Description copied from interface: IQueueExtent
      Must ensure it is not in the queue handler (i.e. does not change blocks in the world)
      Specified by:
      disableQueue in interface Extent
      Specified by:
      disableQueue in interface IQueueExtent<IQueueChunk>
    • getCachedGet

      public IChunkGet getCachedGet(int chunkX, int chunkZ)
      Description copied from interface: IQueueExtent
      Get the cached get object. This is faster than getting the object using NMS and allows for wrapping.
      Specified by:
      getCachedGet in interface IQueueExtent<IQueueChunk>
    • getCachedSet

      public IChunkSet getCachedSet(int chunkX, int chunkZ)
      Description copied from interface: IQueueExtent
      Get the cached chunk set object.
      Specified by:
      getCachedSet in interface IQueueExtent<IQueueChunk>
    • isFastMode

      public boolean isFastMode()
      Specified by:
      isFastMode in interface IQueueExtent<IQueueChunk>
    • setFastMode

      public void setFastMode(boolean fastmode)
      Specified by:
      setFastMode in interface IQueueExtent<IQueueChunk>
    • getMinY

      public int getMinY()
      Specified by:
      getMinY in interface Extent
    • getMaxY

      public int getMaxY()
      Specified by:
      getMaxY in interface Extent
    • setFaweExceptionArray

      public void setFaweExceptionArray(boolean[] faweExceptionReasonsUsed)
      Sets the cached boolean array of length FaweException.Type.values().length that determines if a thrown FaweException of type FaweException.Type should be output to console, rethrown to attempt to be visible to the player, etc. Allows the same array to be used as widely as possible across the edit to avoid spam to console.
      Parameters:
      faweExceptionReasonsUsed - boolean array that should be cached where this method is called from of length FaweException.Type.values().length
    • reset

      protected void reset()
      Resets the queue.
    • init

      public void init(Extent extent, IChunkCache<IChunkGet> get, IChunkCache<IChunkSet> set)
      Initialize the queue
      Specified by:
      init in interface IQueueExtent<IQueueChunk>
      Parameters:
      extent - extent to use
      get - cache of chunk GET
      set - cache of chunk SET
    • size

      public int size()
      Description copied from interface: IQueueExtent
      Returns the number of chunks in this queue.
      Specified by:
      size in interface IQueueExtent<IQueueChunk>
      Returns:
      the number of chunks in this queue
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface IQueueExtent<IQueueChunk>
      Returns:
      true if this queue contains no elements
    • submit

      public <V extends Future<V>> V submit(IQueueChunk chunk)
      Description copied from interface: IQueueExtent
      Submit the chunk so that it's changes are applied to the world
      Specified by:
      submit in interface IQueueExtent<IQueueChunk>
      Returns:
      Future
    • trim

      public boolean trim(boolean aggressive)
      Description copied from interface: Trimable
      Trims the object, reducing its memory footprint.
      Specified by:
      trim in interface Trimable
      Parameters:
      aggressive - if trimming should be aggressive e.g., Not returning early when the first element cannot be trimmed
      Returns:
      if this object is empty at the end of the trim, and can therefore be deleted
    • getOrCreateChunk

      public final IQueueChunk getOrCreateChunk(int x, int z)
      Description copied from interface: IChunkExtent
      Get the IChunk at a position (and cache it if it's not already)
      Specified by:
      getOrCreateChunk in interface IChunkExtent<IQueueChunk>
      Returns:
      IChunk
    • addChunkLoad

      public void addChunkLoad(int cx, int cz)
      Load a chunk in the world associated with this SingleThreadQueueExtent instance
      Parameters:
      cx - chunk X coordinate
      cz - chunk Z coordinate
    • preload

      public void preload(Region region)
      Define a region to be "preloaded" to the number of chunks provided by Settings.QUEUE.PRELOAD_CHUNK_COUNT
      Parameters:
      region - region of chunks
    • create

      public ChunkHolder create(boolean isFull)
      Description copied from interface: IQueueExtent
      Create a new root IChunk object. Full chunks will be reused, so a more optimized chunk can be returned in that case.
      Specified by:
      create in interface IQueueExtent<IQueueChunk>
      Parameters:
      isFull - true if a more optimized chunk should be returned
      Returns:
      a more optimized chunk object
      See Also:
    • flush

      public void flush()
      Description copied from interface: IQueueExtent
      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
      Specified by:
      flush in interface IQueueExtent<IQueueChunk>
      Overrides:
      flush in class BatchProcessorHolder
    • initFilterBlock

      public ChunkFilterBlock initFilterBlock()
      Description copied from interface: IQueueExtent
      A filter block is used to iterate over blocks / positions. Essentially combines BlockVector3, Extent and BlockState functions in a way that avoids lookups.
      Specified by:
      initFilterBlock in interface IQueueExtent<IQueueChunk>
    • getScope

      public ProcessorScope getScope()
      Description copied from interface: IBatchProcessor
      Default to CUSTOM ProcessorScope as we want custom processors people add to be before we write history, but after FAWE does it's own stuff.
      Specified by:
      getScope in interface IBatchProcessor
      Overrides:
      getScope in class BatchProcessorHolder