Interface ViewResources


public interface ViewResources
Resource manager for an open DocumentView
  • Method Details

    • getModule

      ResourceModule getModule()
      Gets the resource module.
      Returns:
      Resource module
    • getModuleName

      String getModuleName()
      Gets the name of the resource module
      Returns:
      Resource module name
    • getView

      DocumentView getView()
      Gets the document view these resource belong to.
      Returns:
      View
    • loadItemStack

      Result<org.bukkit.inventory.ItemStack,DelphiException> loadItemStack(String uri)
      Loads an item stack from a JSON file.

      Any errors thrown during the method's execution will be caught and returned in the result.

      If the underlying module is not an IoModule then an erroneous result is returned, otherwise IoModule.loadString(ResourcePath) is called, and it attempts to parse JSON from the returned buffer.

      The item is loaded from minecraft's JSON format. Example:

      
       {
         "id": "minecraft:netherite_sword",
         "count": 1,
         "components": {
           "minecraft:enchantments": {
             "levels": {
               "minecraft:sharpness": 5
             }
           }
         }
       } 
      Result errors
      Error code Description
      ERR_INVALID_PATH The uri could not be parsed into a resource path.
      ERR_API_MODULE If the module is not an IoModule.
      ERR_NO_FILE Module threw a NoSuchFileException
      ERR_ACCESS_DENIED Module threw a AccessDeniedException
      ERR_IO_ERROR Module threw an IOException
      ERR_SYNTAX Failed to parse JSON from file contents
      ERR_SCHEMA_ERROR If the item fails to load from the loaded JSON
      Parameters:
      uri - file path
      Returns:
      Loaded item, or an erroneous result, if the item cannot be loaded for any reason
    • loadDocument

      Result<Document,DelphiException> loadDocument(String uri)
      Attempts to load a document from the specified resource path.

      Any errors thrown during the method's execution will be caught and returned in the result.

      If getModule() is a IoModule then this method attempts to use the IoModule.loadString(ResourcePath) to load the document's XML content. If the underlying module is a ApiModule, then ApiModule.loadDocument(ResourcePath, DocumentContext) is called.

      Result errors
      Error code Description
      ERR_INVALID_PATH The uri could not be parsed into a resource path.
      ERR_MODULE_ERROR If getModule() is an ApiModule and it returned an erroneous result.
      ERR_NO_FILE Module threw a NoSuchFileException
      ERR_ACCESS_DENIED Module threw a AccessDeniedException
      ERR_IO_ERROR Module threw an IOException
      ERR_SAX_PARSER_INIT Failed to instantiate SAX parser to parse the XML document.
      ERR_DOC_PARSE Unrecoverable failure trying to parse the XML data
      ERR_MISSING_PLUGINS One or more of the document's required plugins are missing.The returned exception's message will contain a comma separated list of plugins that it failed to find.
      ERR_UNKNOWN An unknown error caused the document parser to return a null document
      Parameters:
      uri - file path
      Returns:
      Loaded document, or an erroneous result if the document cannot be loaded for any reason.
    • loadStylesheet

      Result<Stylesheet,DelphiException> loadStylesheet(String uri)
      Attempts to load a stylesheet from the specified resource path.

      Any errors thrown during the method's execution will be caught and an erroneous result returned.

      If getModule() is a IoModule then this method attempts to use the IoModule.loadString(ResourcePath) to load the stylesheet. If the underlying module is a ApiModule, then an erroneous result is returned.

      Result errors
      Error code Description
      ERR_INVALID_PATH The uri could not be parsed into a resource path.
      ERR_API_MODULE The underlying module is an ApiModule, stylesheet loading not supported.
      ERR_NO_FILE Module threw a NoSuchFileException
      ERR_ACCESS_DENIED Module threw a AccessDeniedException
      ERR_IO_ERROR Module threw an IOException
      ERR_SYNTAX Unrecoverable failure trying to parse the stylesheet data.
      Parameters:
      uri - file path
      Returns:
      Loaded stylesheet, or an empty result if the stylesheet could not be loaded for any reason
      See Also: