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 LevelBuilderAdds a block with no properties to the level.@NotNull LevelBuilderAdds a block with no properties to the level.@NotNull LevelBuilderblock(@NotNull String name, @NotNull Iterable<Coordinate> coordinates) Adds a block with no properties to the level.@NotNull LevelBuilderblock(@NotNull String name, @NotNull Map<String, Object> properties, @NotNull Iterable<Coordinate> coordinates) Adds a block to the level.@NotNull LevelBuilderAdds a block to the level.@NotNull LevelBuilderblock(@NotNull String name, @NotNull Map<String, Object> properties, @NotNull Coordinate... coordinates) Adds a block to the level.@NotNull LevelBuilderblock(@NotNull String name, @NotNull Coordinate coordinate) Adds a block with no properties to the level.@NotNull LevelBuilderblock(@NotNull String name, @NotNull Coordinate... coordinate) Adds a block with no properties to the level.@NotNull LevelBuilderAdds a block to the level.@NotNull LevelBuilderAdds a block to the level.@NotNull LevelBuilderblock(@NotNull Block block, @NotNull Coordinate coordinate) Adds a block to the level.@NotNull LevelBuilderblock(@NotNull LevelObject block) Adds a block to the level.@NotNull Levelbuild()Builds the level.static @NotNull LevelBuildercreate2D()Creates a 2D Level Builder.static @NotNull LevelBuildercreate3D()Creates a 3D Level Builder.@Unmodifiable @NotNull Set<LevelObject>Gets an immutable copy of the current blocks of the level.@NotNull DimensionGets the current dimension of the level.Gets an immutable copy of the current headers of the level.@NotNull LevelBuilderSets a header value.@NotNull LevelBuilderPerforms a block matrix operation.@NotNull LevelBuildermatrix(@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 LevelBuilderSets the scroll direction for the level.@NotNull LevelBuilderspawn(int[] coords) Sets the spawn point for the level.@NotNull LevelBuilderspawn(@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
-