Class AbstractChangeSet

java.lang.Object
com.fastasyncworldedit.core.history.changeset.AbstractChangeSet
All Implemented Interfaces:
IBatchProcessor, ChangeSet, Closeable, AutoCloseable
Direct Known Subclasses:
AbstractDelegateChangeSet, FaweStreamChangeSet, NullChangeSet

public abstract class AbstractChangeSet extends Object implements ChangeSet, IBatchProcessor
This batch processor writes changes to a concrete implementation. processSet(IChunk, IChunkGet, IChunkSet) is synchronized to guarantee consistency. To avoid many blocking threads on this method, changes are enqueued in queue. This allows to keep other threads free for other work.
  • Field Details

    • closed

      protected volatile boolean closed
  • Constructor Details

    • AbstractChangeSet

      public AbstractChangeSet(World world)
  • Method Details

    • getWorld

      public World getWorld()
    • closeAsync

      public void closeAsync()
    • flush

      public void flush()
      Specified by:
      flush in interface IBatchProcessor
    • close

      public void close() throws IOException
      Description copied from interface: ChangeSet
      Close the changeset.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface ChangeSet
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • add

      public abstract void add(int x, int y, int z, int combinedFrom, int combinedTo)
    • backwardIterator

      public Iterator<Change> backwardIterator()
      Description copied from interface: ChangeSet
      Get a backward directed iterator that can be used for undo.

      The iterator may return the changes out of order, as long as the final result after all changes have been applied is correct.

      Specified by:
      backwardIterator in interface ChangeSet
      Returns:
      a undo directed iterator
    • forwardIterator

      public Iterator<Change> forwardIterator()
      Description copied from interface: ChangeSet
      Get a forward directed iterator that can be used for redo.

      The iterator may return the changes out of order, as long as the final result after all changes have been applied is correct.

      Specified by:
      forwardIterator in interface ChangeSet
      Returns:
      a forward directed iterator
    • construct

      public Extent construct(Extent child)
      Description copied from interface: IBatchProcessor
      Convert this processor into an Extent based processor instead of a queue batch based on.
      Specified by:
      construct in interface IBatchProcessor
    • processSet

      public final IChunkSet processSet(IChunk chunk, IChunkGet get, IChunkSet set)
      Description copied from interface: IBatchProcessor
      Process a chunk that has been set.
      Specified by:
      processSet in interface IBatchProcessor
    • postProcess

      public void postProcess(IChunk chunk, IChunkGet get, IChunkSet set)
      Description copied from interface: IBatchProcessor
      Post-process a chunk that has been edited. Set should NOT be modified here, changes will NOT be flushed to the world, but MAY be flushed to history. Defaults to nothing as most Processors will not use it. If the post-processor will run tasks asynchronously/not be blocking, use IBatchProcessor.postProcessSet(com.fastasyncworldedit.core.queue.IChunk, com.fastasyncworldedit.core.queue.IChunkGet, com.fastasyncworldedit.core.queue.IChunkSet) to return a Future.
      Specified by:
      postProcess in interface IBatchProcessor
    • postProcessSet

      public Future<?> postProcessSet(IChunk chunk, IChunkGet get, IChunkSet set)
      Description copied from interface: IBatchProcessor
      Post-process a chunk that has been edited. Set should NOT be modified here, changes will NOT be flushed to the world, but MAY be flushed to history. Defaults to nothing as most Processors will not use it. Post-processors that are not technically blocking should override this method to allow post-processors to become blocking if required.
      Specified by:
      postProcessSet in interface IBatchProcessor
    • 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
    • addTileCreate

      @Deprecated(forRemoval=true, since="2.11.2") public void addTileCreate(CompoundTag tag)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • addTileCreate

      public abstract void addTileCreate(FaweCompoundTag tag)
      Creates a tile/block entity create change to this change set.
      Parameters:
      tag - the tile/block entity to add.
      Since:
      2.11.2
    • addTileRemove

      @Deprecated(forRemoval=true, since="2.11.2") public void addTileRemove(CompoundTag tag)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • addTileRemove

      public abstract void addTileRemove(FaweCompoundTag tag)
      Creates a tile/block entity remove change to this change set.
      Parameters:
      tag - the tile/block entity to remove.
      Since:
      2.11.2
    • addEntityRemove

      @Deprecated(forRemoval=true, since="2.11.2") public void addEntityRemove(CompoundTag tag)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • addEntityRemove

      public abstract void addEntityRemove(FaweCompoundTag tag)
      Creates an entity remove change to this change set.
      Parameters:
      tag - the entity to remove.
      Since:
      2.11.2
    • addEntityCreate

      @Deprecated(forRemoval=true, since="2.11.2") public void addEntityCreate(CompoundTag tag)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • addEntityCreate

      public abstract void addEntityCreate(FaweCompoundTag tag)
      Creates an entity create change to this change set.
      Parameters:
      tag - the entity to add.
      Since:
      2.11.2
    • addBiomeChange

      public abstract void addBiomeChange(int x, int y, int z, BiomeType from, BiomeType to)
    • getIterator

      public Iterator<Change> getIterator(BlockBag blockBag, int mode, boolean redo)
    • getCoordinatedChanges

      @Internal public abstract ChangeExchangeCoordinator getCoordinatedChanges(BlockBag blockBag, int mode, boolean dir)
      Returns a coordinator to exchange sets of changes between a producer and a consumer.
      Returns:
      a coordinator to exchange sets of changes between a producer and a consumer
      Since:
      2.11.2
    • getIterator

      public abstract Iterator<Change> getIterator(boolean redo)
    • toEditSession

      public EditSession toEditSession(Actor actor)
    • toEditSession

      public EditSession toEditSession(Actor actor, Region[] regions)
    • add

      public void add(EntityCreate change)
    • add

      public void add(EntityRemove change)
    • add

      public void add(Change change)
      Description copied from interface: ChangeSet
      Add the given change to the history.
      Specified by:
      add in interface ChangeSet
      Parameters:
      change - the change
    • add

      public void add(BlockChange change)
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: ChangeSet
      Get if the changeset is empty (i.e. size == 0)
      Specified by:
      isEmpty in interface ChangeSet
      Returns:
      is empty
    • add

      public void add(BlockVector3 loc, BaseBlock from, BaseBlock to)
    • add

      public void add(int x, int y, int z, BaseBlock from, BaseBlock to)
    • add

      public void add(int x, int y, int z, int combinedFrom, BaseBlock to)
    • addWriteTask

      public Future<?> addWriteTask(Runnable writeTask)
    • addWriteTask

      public Future<?> addWriteTask(Runnable writeTask, boolean completeNow)