public interface StructureManager
Modifier and Type | Method and Description |
---|---|
Structure |
copy(Structure structure)
Creates a copy of this structure.
|
Structure |
createStructure()
Creates a new empty structure.
|
void |
deleteStructure(NamespacedKey structureKey)
Unregisters the specified structure and deletes its
structure file from the primary world
folder. |
void |
deleteStructure(NamespacedKey structureKey,
boolean unregister)
Deletes the
structure file for
the specified structure from the primary world folder. |
Structure |
getStructure(NamespacedKey structureKey)
Gets a registered Structure.
|
File |
getStructureFile(NamespacedKey structureKey)
Gets the location where a structure file would exist in the primary world
directory based on the NamespacedKey using the format
world/generated/{NAMESPACE}/structures/{KEY}.nbt.
|
Map<NamespacedKey,Structure> |
getStructures()
Gets the currently registered structures.
|
Structure |
loadStructure(File file)
Reads a Structure from disk.
|
Structure |
loadStructure(InputStream inputStream)
Reads a Structure from a stream.
|
Structure |
loadStructure(NamespacedKey structureKey)
Loads the structure for the specified key and automatically registers it.
|
Structure |
loadStructure(NamespacedKey structureKey,
boolean register)
Loads a structure for the specified key and optionally
registers it. |
Structure |
registerStructure(NamespacedKey structureKey,
Structure structure)
Registers the given structure.
|
void |
saveStructure(File file,
Structure structure)
Save a structure to a file.
|
void |
saveStructure(NamespacedKey structureKey)
Saves the currently
registered structure for the
specified key to the primary world folder as
specified by {#getStructureFile(NamespacedKey}. |
void |
saveStructure(NamespacedKey structureKey,
Structure structure)
Saves a structure with a given key to the primary world folder.
|
void |
saveStructure(OutputStream outputStream,
Structure structure)
Save a structure to a stream.
|
Structure |
unregisterStructure(NamespacedKey structureKey)
Unregisters a structure.
|
@NotNull Map<NamespacedKey,Structure> getStructures()
These are the currently loaded structures that the StructureManager is
aware of. When a structure block refers to a structure, these structures
are checked first. If the specified structure is not found among the
currently registered structures, the StructureManager may dynamically
read the structure from the primary world folder, DataPacks, or the
server's own resources. Structures can be registered via registerStructure(NamespacedKey, Structure)
@Nullable Structure getStructure(@NotNull NamespacedKey structureKey)
structureKey
- The key for which to get the structurenull
if there is none registered for that key.@Nullable Structure registerStructure(@NotNull NamespacedKey structureKey, @NotNull Structure structure)
getStructures()
.structureKey
- The key for which to register the structurestructure
- The structure to registernull
if the
structure could not be found.@Nullable Structure unregisterStructure(@NotNull NamespacedKey structureKey)
structureKey
- The key for which to save the structure fornull
if there was none@Nullable Structure loadStructure(@NotNull NamespacedKey structureKey, boolean register)
registers
it.
This will first check the already loaded registered structures
, and otherwise load the structure from the primary
world folder, DataPacks, and the server's own resources (in this order).
When loading the structure from the primary world folder, the given key
is translated to a file as specified by
getStructureFile(NamespacedKey)
.
structureKey
- The key for which to load the structureregister
- true
to register the loaded structure.null
if no structure was found for
the specified key@Nullable Structure loadStructure(@NotNull NamespacedKey structureKey)
loadStructure(NamespacedKey, boolean)
.structureKey
- The key for which to load the structurenull
if the
structure could not be found.void saveStructure(@NotNull NamespacedKey structureKey)
registered structure
for the
specified key
to the primary world folder as
specified by {#getStructureFile(NamespacedKey}.structureKey
- The key for which to save the structure forvoid saveStructure(@NotNull NamespacedKey structureKey, @NotNull Structure structure) throws IOException
structureKey
- The key for which to save the structure forstructure
- The structure to save for this structureKeyIOException
void deleteStructure(@NotNull NamespacedKey structureKey) throws IOException
structure file
from the primary world
folder. Note that this method cannot be used to delete vanilla Minecraft
structures, or structures from DataPacks. Unregistering these structures
will however work fine.structureKey
- The key of the structure to removeIOException
- If the file could not be removed for some reason.void deleteStructure(@NotNull NamespacedKey structureKey, boolean unregister) throws IOException
structure file
for
the specified structure from the primary world folder. Note that this
method cannot be used to delete vanilla Minecraft structures, or
structures from DataPacks. Unregistering these structures will however
work fine.structureKey
- The key of the structure to removeunregister
- Whether to also unregister the specified structure if
it is currently loaded.IOException
- If the file could not be removed for some reason.@NotNull File getStructureFile(@NotNull NamespacedKey structureKey)
structureKey
- The key to build the filepath from.@NotNull Structure loadStructure(@NotNull File file) throws IOException
file
- The file of the structureIOException
- when the given file can not be read from@NotNull Structure loadStructure(@NotNull InputStream inputStream) throws IOException
inputStream
- The file of the structureIOException
void saveStructure(@NotNull File file, @NotNull Structure structure) throws IOException
file
- the target to save to.structure
- the Structure to save.IOException
- when the given file can not be written to.void saveStructure(@NotNull OutputStream outputStream, @NotNull Structure structure) throws IOException
outputStream
- the stream to write to.structure
- the Structure to save.IOException
- when the given file can not be written to.@NotNull Structure createStructure()
Copyright © 2022. All rights reserved.