Package xyz.calcugames.levelz.builder
Class LevelBuilder
java.lang.Object
xyz.calcugames.levelz.builder.LevelBuilder
Represents a builder for creating LevelZ Levels.
-
Method Summary
Modifier and TypeMethodDescription@NotNull LevelBuilder
Adds a block with no properties to the level.@NotNull LevelBuilder
Adds a block with no properties to the level.@NotNull LevelBuilder
block
(@NotNull String name, @NotNull Iterable<Coordinate> coordinates) Adds a block with no properties to the level.@NotNull LevelBuilder
block
(@NotNull String name, @NotNull Map<String, Object> properties, @NotNull Iterable<Coordinate> coordinates) Adds a block to the level.@NotNull LevelBuilder
Adds a block to the level.@NotNull LevelBuilder
block
(@NotNull String name, @NotNull Map<String, Object> properties, @NotNull Coordinate... coordinates) Adds a block to the level.@NotNull LevelBuilder
block
(@NotNull String name, @NotNull Coordinate coordinate) Adds a block with no properties to the level.@NotNull LevelBuilder
block
(@NotNull String name, @NotNull Coordinate... coordinate) Adds a block with no properties to the level.@NotNull LevelBuilder
Adds a block to the level.@NotNull LevelBuilder
Adds a block to the level.@NotNull LevelBuilder
block
(@NotNull Block block, @NotNull Coordinate coordinate) Adds a block to the level.@NotNull LevelBuilder
block
(@NotNull LevelObject block) Adds a block to the level.@NotNull Level
build()
Builds the level.static @NotNull LevelBuilder
create2D()
Creates a 2D Level Builder.static @NotNull LevelBuilder
create3D()
Creates a 3D Level Builder.@Unmodifiable @NotNull Set<LevelObject>
Gets an immutable copy of the current blocks of the level.@NotNull Dimension
Gets the current dimension of the level.Gets an immutable copy of the current headers of the level.@NotNull LevelBuilder
Sets a header value.@NotNull LevelBuilder
Performs a block matrix operation.@NotNull LevelBuilder
matrix
(@NotNull Block block, int cx, int cy, int cz, int x1, int x2, int y1, int y2, int z1, int z2) Performs a block matrix operation.@NotNull LevelBuilder
Sets the scroll direction for the level.@NotNull LevelBuilder
spawn
(int[] coords) Sets the spawn point for the level.@NotNull LevelBuilder
spawn
(@NotNull Coordinate spawn) Sets the spawn point for the level.
-
Method Details
-
create2D
Creates a 2D Level Builder.- Returns:
- 2D Level Builder
-
create3D
Creates a 3D Level Builder.- Returns:
- 3D Level Builder
-
spawn
Sets the spawn point for the level.- Parameters:
spawn
- Spawn Point- Returns:
- this class, for chaining
-
spawn
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 Keyvalue
- 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
- Blockcoordinate
- 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
- Blockx
- X Coordinatey
- 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
- Blockx
- X Coordinatey
- Y Coordinatez
- 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 Nameproperties
- Block Propertiescoordinate
- 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 Nameproperties
- Block Propertiescoordinates
- 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 Nameproperties
- Block Propertiescoordinates
- 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 Namecoordinate
- 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 Namecoordinate
- 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 Namecoordinates
- Iterable of Block Coordinates- Returns:
- this class, for chaining
-
block
Adds a block with no properties to the level.- Parameters:
name
- Block Namex
- X Coordinatey
- Y Coordinate- Returns:
- this class, for chaining
-
block
Adds a block with no properties to the level.- Parameters:
name
- Block Namex
- X Coordinatey
- Y Coordinatez
- Z Coordinate- 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
- Blockcx
- Center Xcy
- Center Yx1
- First X Coordinatex2
- Second X Coordinatey1
- First Y Coordinatey2
- 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
- Blockcx
- Center Xcy
- Center Ycz
- Center Zx1
- First X Coordinatex2
- Second X Coordinatey1
- First Y Coordinatey2
- Second Y Coordinatz1
- First Z Coordinatez2
- Second Z Coordinate- Returns:
- this class, for chaining
- Throws:
IllegalArgumentException
- If the dimension is not 2D, or first is bigger than second
-
getDimension
Gets the current dimension of the level.- Returns:
- Level Dimension
-
getHeaders
Gets an immutable copy of the current headers of the level.- Returns:
- Level Headers
-
getBlocks
Gets an immutable copy of the current blocks of the level.- Returns:
- Level Blocks
-
build
Builds the level.- Returns:
- Level
-