Class LevelBuilder

java.lang.Object
xyz.calcugames.levelz.builder.LevelBuilder

public final class LevelBuilder extends Object
Represents a builder for creating LevelZ Levels.
  • Method Details

    • create2D

      @NotNull public static @NotNull LevelBuilder create2D()
      Creates a 2D Level Builder.
      Returns:
      2D Level Builder
    • create3D

      @NotNull public static @NotNull LevelBuilder create3D()
      Creates a 3D Level Builder.
      Returns:
      3D Level Builder
    • spawn

      @NotNull public @NotNull LevelBuilder spawn(@NotNull @NotNull Coordinate spawn)
      Sets the spawn point for the level.
      Parameters:
      spawn - Spawn Point
      Returns:
      this class, for chaining
    • spawn

      @NotNull public @NotNull LevelBuilder spawn(int[] coords)
      Sets the spawn point for the level.
      Parameters:
      coords - Spawn Point
      Returns:
      this class, for chaining
    • scroll

      @NotNull public @NotNull LevelBuilder scroll(@Nullable @Nullable Scroll scroll) throws IllegalArgumentException
      Sets the scroll direction for the level.
      Parameters:
      scroll - Scroll Direction
      Returns:
      this class, for chaining
      Throws:
      IllegalArgumentException - If the level is not 2D
    • header

      @NotNull public @NotNull LevelBuilder header(@NotNull @NotNull String key, @Nullable @Nullable String value) throws IllegalArgumentException
      Sets a header value.
      Parameters:
      key - Header Key
      value - Header Value, can be null
      Returns:
      this class, for chaining
      Throws:
      IllegalArgumentException - If the key is null
    • block

      @NotNull public @NotNull LevelBuilder block(@NotNull @NotNull LevelObject block) throws IllegalArgumentException
      Adds a block to the level.
      Parameters:
      block - Level Block
      Returns:
      this class, for chaining
      Throws:
      IllegalArgumentException - If the block coordinate is not the same dimension as the level
    • block

      @NotNull public @NotNull LevelBuilder block(@NotNull @NotNull Block block, @NotNull @NotNull Coordinate coordinate)
      Adds a block to the level.
      Parameters:
      block - Block
      coordinate - Coordinate
      Returns:
      this class, for chaining
    • block

      @NotNull public @NotNull LevelBuilder block(@NotNull @NotNull Block block, int x, int y) throws IllegalArgumentException
      Adds a block to the level.
      Parameters:
      block - Block
      x - X Coordinate
      y - Y Coordinate
      Returns:
      this class, for chaining
      Throws:
      IllegalArgumentException - If the dimension is not 2D
    • block

      @NotNull public @NotNull LevelBuilder block(@NotNull @NotNull Block block, int x, int y, int z) throws IllegalArgumentException
      Adds a block to the level.
      Parameters:
      block - Block
      x - X Coordinate
      y - Y Coordinate
      z - Z Coordinate
      Returns:
      this class, for chaining
      Throws:
      IllegalArgumentException - If the dimension is not 3D
    • block

      @NotNull public @NotNull LevelBuilder block(@NotNull @NotNull String name, @NotNull @NotNull Map<String,Object> properties, @NotNull @NotNull Coordinate coordinate)
      Adds a block to the level.
      Parameters:
      name - Block Name
      properties - Block Properties
      coordinate - Block Coordinate
      Returns:
      this class, for chaining
    • block

      @NotNull public @NotNull LevelBuilder block(@NotNull @NotNull String name, @NotNull @NotNull Map<String,Object> properties, @NotNull @NotNull Coordinate... coordinates)
      Adds a block to the level.
      Parameters:
      name - Block Name
      properties - Block Properties
      coordinates - Array of Block Coordinates
      Returns:
      this class, for chaining
    • block

      @NotNull public @NotNull LevelBuilder block(@NotNull @NotNull String name, @NotNull @NotNull Map<String,Object> properties, @NotNull @NotNull Iterable<Coordinate> coordinates)
      Adds a block to the level.
      Parameters:
      name - Block Name
      properties - Block Properties
      coordinates - Iterable of Block Coordinates
      Returns:
      this class, for chaining
    • block

      @NotNull public @NotNull LevelBuilder block(@NotNull @NotNull String name, @NotNull @NotNull Coordinate coordinate)
      Adds a block with no properties to the level.
      Parameters:
      name - Block Name
      coordinate - Block Coordinate
      Returns:
      this class, for chaining
    • block

      @NotNull public @NotNull LevelBuilder block(@NotNull @NotNull String name, @NotNull @NotNull Coordinate... coordinate)
      Adds a block with no properties to the level.
      Parameters:
      name - Block Name
      coordinate - Block Coordinate
      Returns:
      this class, for chaining
    • block

      @NotNull public @NotNull LevelBuilder block(@NotNull @NotNull String name, @NotNull @NotNull Iterable<Coordinate> coordinates)
      Adds a block with no properties to the level.
      Parameters:
      name - Block Name
      coordinates - Iterable of Block Coordinates
      Returns:
      this class, for chaining
    • matrix

      @NotNull public @NotNull LevelBuilder matrix(@NotNull @NotNull Block block, int cx, int cy, int x1, int x2, int y1, int y2) throws IllegalArgumentException
      Performs a block matrix operation.
      Parameters:
      block - Block
      cx - Center X
      cy - Center Y
      x1 - First X Coordinate
      x2 - Second X Coordinate
      y1 - First Y Coordinate
      y2 - Second Y Coordinate
      Returns:
      this class, for chaining
      Throws:
      IllegalArgumentException - If the dimension is not 2D, or first is bigger than second
    • matrix

      @NotNull public @NotNull LevelBuilder matrix(@NotNull @NotNull Block block, int cx, int cy, int cz, int x1, int x2, int y1, int y2, int z1, int z2) throws IllegalArgumentException
      Performs a block matrix operation.
      Parameters:
      block - Block
      cx - Center X
      cy - Center Y
      cz - Center Z
      x1 - First X Coordinate
      x2 - Second X Coordinate
      y1 - First Y Coordinate
      y2 - Second Y Coordinat
      z1 - First Z Coordinate
      z2 - Second Z Coordinate
      Returns:
      this class, for chaining
      Throws:
      IllegalArgumentException - If the dimension is not 2D, or first is bigger than second
    • getDimension

      @NotNull public @NotNull Dimension getDimension()
      Gets the current dimension of the level.
      Returns:
      Level Dimension
    • getHeaders

      @NotNull public @Unmodifiable @NotNull Map<String,String> getHeaders()
      Gets an immutable copy of the current headers of the level.
      Returns:
      Level Headers
    • getBlocks

      @NotNull public @Unmodifiable @NotNull Set<LevelObject> getBlocks()
      Gets an immutable copy of the current blocks of the level.
      Returns:
      Level Blocks
    • build

      @NotNull public @NotNull Level build()
      Builds the level.
      Returns:
      Level