接口 StructureManager
-
方法概要
修饰符和类型方法说明Creates a copy of this structure.Creates a new empty structure.void
deleteStructure
(@NotNull NamespacedKey structureKey) Unregisters the specified structure and deletes itsstructure file
from the primary world folder.void
deleteStructure
(@NotNull NamespacedKey structureKey, boolean unregister) Deletes thestructure file
for the specified structure from the primary world folder.getStructure
(@NotNull NamespacedKey structureKey) Gets a registered Structure.getStructureFile
(@NotNull 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.Gets the currently registered structures.loadStructure
(@NotNull File file) Reads a Structure from disk.loadStructure
(@NotNull InputStream inputStream) Reads a Structure from a stream.loadStructure
(@NotNull NamespacedKey structureKey) Loads the structure for the specified key and automatically registers it.loadStructure
(@NotNull NamespacedKey structureKey, boolean register) Loads a structure for the specified key and optionallyregisters
it.registerStructure
(@NotNull NamespacedKey structureKey, @NotNull Structure structure) Registers the given structure.void
saveStructure
(@NotNull File file, @NotNull Structure structure) Save a structure to a file.void
saveStructure
(@NotNull OutputStream outputStream, @NotNull Structure structure) Save a structure to a stream.void
saveStructure
(@NotNull NamespacedKey structureKey) Saves the currentlyregistered structure
for the specifiedkey
to the primary world folder as specified by {#getStructureFile(NamespacedKey}.void
saveStructure
(@NotNull NamespacedKey structureKey, @NotNull Structure structure) Saves a structure with a given key to the primary world folder.unregisterStructure
(@NotNull NamespacedKey structureKey) Unregisters a structure.
-
方法详细资料
-
getStructures
Gets the currently registered structures.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)
- 返回:
- an unmodifiable shallow copy of the currently registered structures
-
getStructure
Gets a registered Structure.- 参数:
structureKey
- The key for which to get the structure- 返回:
- The structure that belongs to the structureKey or
null
if there is none registered for that key.
-
registerStructure
@Nullable @Nullable Structure registerStructure(@NotNull @NotNull NamespacedKey structureKey, @NotNull @NotNull Structure structure) Registers the given structure. SeegetStructures()
.- 参数:
structureKey
- The key for which to register the structurestructure
- The structure to register- 返回:
- The structure for the specified key, or
null
if the structure could not be found.
-
unregisterStructure
Unregisters a structure. Unregisters the specified structure. If the structure still exists in the primary world folder, a DataPack, or is part of the server's own resources, it may be loaded and registered again when it is requested by a plugin or the server itself.- 参数:
structureKey
- The key for which to save the structure for- 返回:
- The structure that was registered for that key or
null
if there was none
-
loadStructure
@Nullable @Nullable Structure loadStructure(@NotNull @NotNull NamespacedKey structureKey, boolean register) Loads a structure for the specified key and optionallyregisters
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.- 返回:
- The structure, or
null
if no structure was found for the specified key
-
loadStructure
Loads the structure for the specified key and automatically registers it. SeeloadStructure(NamespacedKey, boolean)
.- 参数:
structureKey
- The key for which to load the structure- 返回:
- The structure for the specified key, or
null
if the structure could not be found.
-
saveStructure
Saves the currentlyregistered structure
for the specifiedkey
to the primary world folder as specified by {#getStructureFile(NamespacedKey}.- 参数:
structureKey
- The key for which to save the structure for
-
saveStructure
void saveStructure(@NotNull @NotNull NamespacedKey structureKey, @NotNull @NotNull Structure structure) throws IOException Saves a structure with a given key to the primary world folder.- 参数:
structureKey
- The key for which to save the structure forstructure
- The structure to save for this structureKey- 抛出:
IOException
-
deleteStructure
Unregisters the specified structure and deletes itsstructure 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 remove- 抛出:
IOException
- If the file could not be removed for some reason.
-
deleteStructure
void deleteStructure(@NotNull @NotNull NamespacedKey structureKey, boolean unregister) throws IOException Deletes thestructure 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.
-
getStructureFile
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. This method will always return a file, even if none exists at the moment.- 参数:
structureKey
- The key to build the filepath from.- 返回:
- The location where a file with this key would be.
-
loadStructure
Reads a Structure from disk.- 参数:
file
- The file of the structure- 返回:
- The read structure
- 抛出:
IOException
- when the given file can not be read from
-
loadStructure
@NotNull @NotNull Structure loadStructure(@NotNull @NotNull InputStream inputStream) throws IOException Reads a Structure from a stream.- 参数:
inputStream
- The file of the structure- 返回:
- The read Structure
- 抛出:
IOException
-
saveStructure
void saveStructure(@NotNull @NotNull File file, @NotNull @NotNull Structure structure) throws IOException Save a structure to a file. This will overwrite a file if it already exists.- 参数:
file
- the target to save to.structure
- the Structure to save.- 抛出:
IOException
- when the given file can not be written to.
-
saveStructure
void saveStructure(@NotNull @NotNull OutputStream outputStream, @NotNull @NotNull Structure structure) throws IOException Save a structure to a stream.- 参数:
outputStream
- the stream to write to.structure
- the Structure to save.- 抛出:
IOException
- when the given file can not be written to.
-
createStructure
Creates a new empty structure.- 返回:
- an empty structure.
-
copy
Creates a copy of this structure.- 参数:
structure
- The structure to copy- 返回:
- a copy of the structure
-