Class StructureBuilder
You can create a structure completely via code or load a structure from a yaml file.
Example using a yaml file:
StructureBuilder builder = new StructureBuilder("MyName", file);
Structure struct = builder.build();
Example using code:
StructureBuilder builder = new StructureBuilder("MyName", file);
builder.setStructureLimitations(new StructureLimitations());
...
Structure struct = builder.build();
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AdvancedSubSchematicsprotected doubleprotected BottomSpaceFillprotected Stringprotected booleanprotected Map<LootTableType,RandomCollection<LootTable>>protected Stringprotected intprotected intprotected intprotected Stringprotected MaskPropertyprotected StructureLimitationsprotected StructureLocationprotected StructurePropertiesprotected List<StructureSection>protected SubSchematicsprotected MaskProperty -
Constructor Summary
ConstructorsConstructorDescriptionStructureBuilder(String name, File file)Build a structure using a yaml configuration file.StructureBuilder(String name, String schematic)Build a structure using code.StructureBuilder(String name, String schematic, StructureSection... sections)Build a structure.StructureBuilder(String name, String schematic, List<StructureSection> sections)Build a structure. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLootTable(LootTable lootTable, double weight)Add a loot table to the structure.voidaddStructureSection(StructureSection structureSection)Add a structure section to the structure builder.build()Build the structure.voidSave the structure as a structure configuration file.voidsetAdvancedSubSchematics(AdvancedSubSchematics advancedSubSchematics)Set the advanced sub-schematic property.voidsetBaseRotation(double baseRotation)Set the base rotation of a structure.voidsetBottomSpaceFill(BottomSpaceFill bottomSpaceFill)Set the bottom space fill property.voidsetCompiledSchematic(String cschem)Set the compiled schematic.voidsetLootTables(Map<LootTableType,RandomCollection<LootTable>> lootTables)Set the loot tables using a collection of LootTable.voidsetLootTables(org.bukkit.configuration.ConfigurationSection lootableConfig)Set the loot tables from a configuration section.voidsetPriority(int priority)Set the priority of the structure.voidsetProbability(int numerator, int denominator)Set the probability of the structure spawning.voidSet the source mask property.voidsetStructureLimitations(StructureLimitations limitations)Set the structure limitations.voidsetStructureLocation(StructureLocation location)Set the structure location.voidsetStructureProperties(StructureProperties properties)Set the structure properties.voidsetSubSchematics(SubSchematics subSchematics)Set the (simple) sub-schematic property.voidSet the target mask property.
-
Field Details
-
name
-
schematic
-
probabilityNumerator
protected int probabilityNumerator -
probabilityDenominator
protected int probabilityDenominator -
priority
protected int priority -
compiledSchematic
-
isCompiled
protected boolean isCompiled -
structureLocation
-
structureProperties
-
structureLimitations
-
sourceMaskProperty
-
targetMaskProperty
-
subSchematics
-
advancedSubSchematics
-
bottomSpaceFill
-
lootTables
-
structureSections
-
baseRotation
protected double baseRotation
-
-
Constructor Details
-
StructureBuilder
Build a structure using code.- Parameters:
name- The name of the structure.schematic- The schematic of the structure.
-
StructureBuilder
Build a structure.- Parameters:
name- The name of the structure.schematic- The location of the structure schematic file.sections- The list of structure sections.
-
StructureBuilder
Build a structure.- Parameters:
name- The name of the structure.schematic- The location of the structure schematic file.sections- The structure sections to add.
-
StructureBuilder
Build a structure using a yaml configuration file.No further editing of this class is required if you use this method.
Errors are outputted to the console. If an error occurs
build()will return null.- Parameters:
name- The name of the structure.file- The file to read from.
-
-
Method Details
-
setProbability
public void setProbability(int numerator, int denominator)Set the probability of the structure spawning.How many times (numerator) a structure should spawn per x (denominator) chunks.
- Parameters:
numerator- The numerator of the probability fraction.denominator- The denominator of the probability fraction.
-
setPriority
public void setPriority(int priority)Set the priority of the structure.The lower the number, the greater the priority.
- Parameters:
priority- The priority of the structure. (Default 100).
-
setCompiledSchematic
Set the compiled schematic.This will automatically set isCompiled to true if the file is found.
- Parameters:
cschem- The compiled schematic name. (Include the .cschem)This file MUST be in the schematics folder.
An IllegalArgumentException is thrown when the file is not found.
-
setStructureLimitations
Set the structure limitations.- Parameters:
limitations- The structure limitations.
-
setStructureProperties
Set the structure properties.- Parameters:
properties- The structure properties.
-
setStructureLocation
Set the structure location.- Parameters:
location- The structure location.
-
setSourceMaskProperty
Set the source mask property.- Parameters:
mask- The source mask property.
-
setTargetMaskProperty
Set the target mask property.- Parameters:
mask- The target mask property.
-
setBottomSpaceFill
Set the bottom space fill property.- Parameters:
bottomSpaceFill- The bottom space fill property.
-
setSubSchematics
Set the (simple) sub-schematic property.- Parameters:
subSchematics- The sub-schematic property.
-
setAdvancedSubSchematics
Set the advanced sub-schematic property.- Parameters:
advancedSubSchematics- The advanced sub-schematic property.
-
setLootTables
public void setLootTables(org.bukkit.configuration.ConfigurationSection lootableConfig)Set the loot tables from a configuration section.- Parameters:
lootableConfig- The loot table configuration section.
-
setLootTables
Set the loot tables using a collection of LootTable.- Parameters:
lootTables- The collection of LootTables.
-
addLootTable
Add a loot table to the structure.- Parameters:
lootTable- The loot table to add.weight- The weight.
-
setBaseRotation
public void setBaseRotation(double baseRotation)Set the base rotation of a structure.This is an API only functionality. It sets what the structure should be rotated by, while still allowing for random rotation is desired.
- Parameters:
baseRotation- The base rotation of a structure. (In Radians.)
-
addStructureSection
Add a structure section to the structure builder.Note:
StructureSection.setupSection(ConfigurationSection)is NOT called by this method. You are expected to use a constructor.- Parameters:
structureSection- The structure section to add.
-
build
Build the structure.Note: This does not check to see if all values are set. If any of the properties are not set than a NullPointerException will occur.
- Returns:
- The structure.
-
save
Save the structure as a structure configuration file.This automatically saves the file in the structures folder.
- Parameters:
file- The file to save.- Throws:
IOException- If an IO Exception occurs.
-