Class StructureSaverAbstractImpl<L,V>

java.lang.Object
com.github.shynixn.structureblocklib.core.entity.StructureSaverAbstractImpl<L,V>
All Implemented Interfaces:
com.github.shynixn.structureblocklib.api.entity.StructureSaverAbstract<L,V>

public class StructureSaverAbstractImpl<L,V> extends Object implements com.github.shynixn.structureblocklib.api.entity.StructureSaverAbstract<L,V>
Interface fluent API to save structures from the world into different targets.
  • Constructor Summary

    Constructors
    Constructor
    Description
    StructureSaverAbstractImpl(com.github.shynixn.structureblocklib.api.service.ProxyService proxyService, com.github.shynixn.structureblocklib.api.service.StructureSerializationService serializationService, com.github.shynixn.structureblocklib.api.service.StructureWorldService worldService)
    Creates a new raw structure save instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull com.github.shynixn.structureblocklib.api.entity.StructureSaverAbstract<L,V>
    at(L location)
    Sets the source Location corner where the blocks start to get saved.
    com.github.shynixn.structureblocklib.api.entity.StructureSaverAbstract<L,V>
    author(@Nullable String author)
    Sets the author.
    @Nullable String
    Gets the author.
    Gets the target Location.
    Gets the offset of the selection.
    @NotNull com.github.shynixn.structureblocklib.api.enumeration.StructureRestriction
    Gets the size restriction.
    @NotNull String
    Gets the name of the block type which is being used as a Structure_Void.
    com.github.shynixn.structureblocklib.api.entity.StructureSaverAbstract<L,V>
    includeEntities(boolean enabled)
    Should entities be included in the save file.
    boolean
    Should entities included in the saved file.
    @NotNull com.github.shynixn.structureblocklib.api.entity.StructureSaverAbstract<L,V>
    offSet(V vector)
    Sets the source Vector offset where the blocks reach to get saved.
    @NotNull com.github.shynixn.structureblocklib.api.entity.StructureSaverAbstract<L,V>
    restriction(@NotNull com.github.shynixn.structureblocklib.api.enumeration.StructureRestriction structureRestriction)
    Restricts the structure to a certain size if a larger area is selected with offset.
    @NotNull com.github.shynixn.structureblocklib.api.entity.ProgressToken<Void>
    saveToFile(@NotNull File target)
    Saves the blocks and entities from the world into into a structure.nbt file.
    @NotNull com.github.shynixn.structureblocklib.api.entity.ProgressToken<Void>
    Saves the blocks and entities from the world into into a structure.nbt binary stream.
    @NotNull com.github.shynixn.structureblocklib.api.entity.ProgressToken<Void>
    saveToPath(@NotNull Path target)
    Saves the blocks and entities from the world into into a structure.nbt file.
    @NotNull com.github.shynixn.structureblocklib.api.entity.ProgressToken<String>
    Saves the blocks and entities from the world into into a structure.nbt binary as Base64 encoded string.
    @NotNull com.github.shynixn.structureblocklib.api.entity.ProgressToken<Void>
    saveToWorld(@NotNull String worldName, @NotNull String author, @NotNull String name)
    Saves the blocks and entities from the world into into a structure.nbt file located in the world folder, author folder.
    @NotNull com.github.shynixn.structureblocklib.api.entity.StructureSaverAbstract<L,V>
    sizeX(int x)
    Sets the offset in x coordinate.
    @NotNull com.github.shynixn.structureblocklib.api.entity.StructureSaverAbstract<L,V>
    sizeY(int y)
    Sets the offset in y coordinate.
    @NotNull com.github.shynixn.structureblocklib.api.entity.StructureSaverAbstract<L,V>
    sizeZ(int z)
    Sets the offset in z coordinate.
    @NotNull com.github.shynixn.structureblocklib.api.entity.StructureSaverAbstract<L,V>
    Sets the name of the block type which is being used as a Structure_Void.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • StructureSaverAbstractImpl

      public StructureSaverAbstractImpl(com.github.shynixn.structureblocklib.api.service.ProxyService proxyService, com.github.shynixn.structureblocklib.api.service.StructureSerializationService serializationService, com.github.shynixn.structureblocklib.api.service.StructureWorldService worldService)
      Creates a new raw structure save instance.
      Parameters:
      proxyService - dependency.
      serializationService - dependency.
      worldService - dependency.
  • Method Details

    • getLocation

      @Nullable public L getLocation()
      Gets the target Location.
      Specified by:
      getLocation in interface com.github.shynixn.structureblocklib.api.entity.StructureSaverAbstract<L,V>
      Returns:
      location.
    • getOffset

      @Nullable public V getOffset()
      Gets the offset of the selection. Has to be smaller or equal to StructureRestriction.
      Specified by:
      getOffset in interface com.github.shynixn.structureblocklib.api.entity.StructureSaverAbstract<L,V>
      Returns:
      offset.
    • getAuthor

      @Nullable public @Nullable String getAuthor()
      Gets the author. The author is a optional meta data in the final structure file.
      Specified by:
      getAuthor in interface com.github.shynixn.structureblocklib.api.entity.StructureSaverAbstract<L,V>
      Returns:
      author.
    • isIncludeEntitiesEnabled

      public boolean isIncludeEntitiesEnabled()
      Should entities included in the saved file. Default false.
      Specified by:
      isIncludeEntitiesEnabled in interface com.github.shynixn.structureblocklib.api.entity.StructureSaverAbstract<L,V>
      Returns:
      flag.
    • getRestriction

      @NotNull public @NotNull com.github.shynixn.structureblocklib.api.enumeration.StructureRestriction getRestriction()
      Gets the size restriction.

      Default StructureRestriction.SINGLE_32.

      Specified by:
      getRestriction in interface com.github.shynixn.structureblocklib.api.entity.StructureSaverAbstract<L,V>
      Returns:
      restriction.
    • getStructureVoidTypeName

      @NotNull public @NotNull String getStructureVoidTypeName()
      Gets the name of the block type which is being used as a Structure_Void.

      Default STRUCTURE_VOID in 1.10 - Latest, BARRIER_BLOCK in 1.9.

      If the selected structure contains blocks with this typename. They are going to get ignored.

      Specified by:
      getStructureVoidTypeName in interface com.github.shynixn.structureblocklib.api.entity.StructureSaverAbstract<L,V>
      Returns:
      Name of the block type.
    • at

      @NotNull public @NotNull com.github.shynixn.structureblocklib.api.entity.StructureSaverAbstract<L,V> at(@Nullable L location)
      Sets the source Location corner where the blocks start to get saved. Required parameter.
      Specified by:
      at in interface com.github.shynixn.structureblocklib.api.entity.StructureSaverAbstract<L,V>
      Parameters:
      location - Location.
      Returns:
      This instance.
    • offSet

      @NotNull public @NotNull com.github.shynixn.structureblocklib.api.entity.StructureSaverAbstract<L,V> offSet(@Nullable V vector)
      Sets the source Vector offset where the blocks reach to get saved. Required parameter.
      Specified by:
      offSet in interface com.github.shynixn.structureblocklib.api.entity.StructureSaverAbstract<L,V>
      Parameters:
      vector - Vector.
      Returns:
      This instance.
    • sizeX

      @NotNull public @NotNull com.github.shynixn.structureblocklib.api.entity.StructureSaverAbstract<L,V> sizeX(int x)
      Sets the offset in x coordinate.
      Specified by:
      sizeX in interface com.github.shynixn.structureblocklib.api.entity.StructureSaverAbstract<L,V>
      Parameters:
      x - offset.
      Returns:
      This instance.
    • sizeY

      @NotNull public @NotNull com.github.shynixn.structureblocklib.api.entity.StructureSaverAbstract<L,V> sizeY(int y)
      Sets the offset in y coordinate.
      Specified by:
      sizeY in interface com.github.shynixn.structureblocklib.api.entity.StructureSaverAbstract<L,V>
      Parameters:
      y - offset.
      Returns:
      This instance.
    • sizeZ

      @NotNull public @NotNull com.github.shynixn.structureblocklib.api.entity.StructureSaverAbstract<L,V> sizeZ(int z)
      Sets the offset in z coordinate.
      Specified by:
      sizeZ in interface com.github.shynixn.structureblocklib.api.entity.StructureSaverAbstract<L,V>
      Parameters:
      z - offset.
      Returns:
      This instance.
    • author

      public com.github.shynixn.structureblocklib.api.entity.StructureSaverAbstract<L,V> author(@Nullable @Nullable String author)
      Sets the author. The author is a optional meta data in the final structure file.
      Specified by:
      author in interface com.github.shynixn.structureblocklib.api.entity.StructureSaverAbstract<L,V>
      Parameters:
      author - name.
      Returns:
      This instance.
    • includeEntities

      public com.github.shynixn.structureblocklib.api.entity.StructureSaverAbstract<L,V> includeEntities(boolean enabled)
      Should entities be included in the save file. Default false.
      Specified by:
      includeEntities in interface com.github.shynixn.structureblocklib.api.entity.StructureSaverAbstract<L,V>
      Parameters:
      enabled - Flag.
      Returns:
      This instance.
    • restriction

      @NotNull public @NotNull com.github.shynixn.structureblocklib.api.entity.StructureSaverAbstract<L,V> restriction(@NotNull @NotNull com.github.shynixn.structureblocklib.api.enumeration.StructureRestriction structureRestriction)
      Restricts the structure to a certain size if a larger area is selected with offset. Default StructureRestriction.SINGLE_32.
      Specified by:
      restriction in interface com.github.shynixn.structureblocklib.api.entity.StructureSaverAbstract<L,V>
      Parameters:
      structureRestriction - Restriction.
      Returns:
      This instance.
    • structureVoidTypeName

      @NotNull public @NotNull com.github.shynixn.structureblocklib.api.entity.StructureSaverAbstract<L,V> structureVoidTypeName(@NotNull @NotNull String name)
      Sets the name of the block type which is being used as a Structure_Void. Default STRUCTURE_VOID in 1.10 - Latest, BARRIER_BLOCK in 1.9.
      Specified by:
      structureVoidTypeName in interface com.github.shynixn.structureblocklib.api.entity.StructureSaverAbstract<L,V>
      Parameters:
      name - Name of the block type.
      Returns:
      This instance.
    • saveToWorld

      @NotNull public @NotNull com.github.shynixn.structureblocklib.api.entity.ProgressToken<Void> saveToWorld(@NotNull @NotNull String worldName, @NotNull @NotNull String author, @NotNull @NotNull String name)
      Saves the blocks and entities from the world into into a structure.nbt file located in the world folder, author folder. Overrides existing files. This allows to use the structure in Vanilla Structure Blocks.

      This call does not block and finishes in the future. Use ProgressToken ()} for cancellation or callbacks.

      Specified by:
      saveToWorld in interface com.github.shynixn.structureblocklib.api.entity.StructureSaverAbstract<L,V>
      Parameters:
      worldName - World where the structure file is stored.
      author - Author of the structure.
      name - Name of the stored structure.
      Returns:
      Instance of ProgressToken.
    • saveToString

      @NotNull public @NotNull com.github.shynixn.structureblocklib.api.entity.ProgressToken<String> saveToString()
      Saves the blocks and entities from the world into into a structure.nbt binary as Base64 encoded string.

      This call does not block and finishes in the future. Use ProgressToken ()} for cancellation or callbacks.

      Specified by:
      saveToString in interface com.github.shynixn.structureblocklib.api.entity.StructureSaverAbstract<L,V>
      Returns:
      Instance of ProgressToken with Base64EncodedString result.
    • saveToPath

      @NotNull public @NotNull com.github.shynixn.structureblocklib.api.entity.ProgressToken<Void> saveToPath(@NotNull @NotNull Path target)
      Saves the blocks and entities from the world into into a structure.nbt file.

      This call does not block and finishes in the future. Use ProgressToken ()} for cancellation or callbacks.

      Specified by:
      saveToPath in interface com.github.shynixn.structureblocklib.api.entity.StructureSaverAbstract<L,V>
      Parameters:
      target - Non existing or existing file. Overrides existing files.
      Returns:
      Instance of ProgressToken.
    • saveToFile

      @NotNull public @NotNull com.github.shynixn.structureblocklib.api.entity.ProgressToken<Void> saveToFile(@NotNull @NotNull File target)
      Saves the blocks and entities from the world into into a structure.nbt file.

      This call does not block and finishes in the future. Use ProgressToken ()} for cancellation or callbacks.

      Specified by:
      saveToFile in interface com.github.shynixn.structureblocklib.api.entity.StructureSaverAbstract<L,V>
      Parameters:
      target - Non existing or existing file. Overrides existing files.
      Returns:
      Instance of ProgressToken.
    • saveToOutputStream

      @NotNull public @NotNull com.github.shynixn.structureblocklib.api.entity.ProgressToken<Void> saveToOutputStream(@NotNull @NotNull OutputStream target)
      Saves the blocks and entities from the world into into a structure.nbt binary stream.

      This call does not block and finishes in the future. Use ProgressToken ()} for cancellation or callbacks.

      Specified by:
      saveToOutputStream in interface com.github.shynixn.structureblocklib.api.entity.StructureSaverAbstract<L,V>
      Parameters:
      target - Open binary outputStream. Does not close the outputStream.
      Returns:
      Instance of ProgressToken.