接口 StructureManager


public interface StructureManager
  • 方法详细资料

    • 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. See getStructures().
      参数:
      structureKey - The key for which to register the structure
      structure - The structure to register
      返回:
      The structure for the specified key, or null if the structure could not be found.
    • unregisterStructure

      @Nullable @Nullable Structure unregisterStructure(@NotNull @NotNull NamespacedKey structureKey)
      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 optionally 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 structure
      register - 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. See loadStructure(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

      void saveStructure(@NotNull @NotNull NamespacedKey structureKey)
      Saves the currently 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 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 for
      structure - The structure to save for this structureKey
      抛出:
      IOException
    • deleteStructure

      void deleteStructure(@NotNull @NotNull NamespacedKey structureKey) throws IOException
      Unregisters the specified structure and deletes its 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 remove
      抛出:
      IOException - If the file could not be removed for some reason.
    • deleteStructure

      void deleteStructure(@NotNull @NotNull NamespacedKey structureKey, boolean unregister) throws IOException
      Deletes the 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 remove
      unregister - Whether to also unregister the specified structure if it is currently loaded.
      抛出:
      IOException - If the file could not be removed for some reason.
    • getStructureFile

      @NotNull @NotNull File getStructureFile(@NotNull @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. 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

      @NotNull @NotNull Structure 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