Interface ViewResources
DocumentView-
Method Summary
Modifier and TypeMethodDescriptionGets the resource module.Gets the name of the resource modulegetView()Gets the document view these resource belong to.loadDocument(String uri) Attempts to load a document from the specified resource path.Result<org.bukkit.inventory.ItemStack, DelphiException> loadItemStack(String uri) Loads an item stack from a JSON file.loadStylesheet(String uri) Attempts to load a stylesheet from the specified resource path.
-
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
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
IoModulethen an erroneous result is returned, otherwiseIoModule.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_PATHThe uricould not be parsed into a resource path.ERR_API_MODULEIf the module is not an IoModule.ERR_NO_FILEModule threw a NoSuchFileExceptionERR_ACCESS_DENIEDModule threw a AccessDeniedExceptionERR_IO_ERRORModule threw an IOExceptionERR_SYNTAXFailed to parse JSON from file contents ERR_SCHEMA_ERRORIf 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
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 aIoModulethen this method attempts to use theIoModule.loadString(ResourcePath)to load the document's XML content. If the underlying module is aApiModule, thenApiModule.loadDocument(ResourcePath, DocumentContext)is called.Result errors Error code Description ERR_INVALID_PATHThe uricould not be parsed into a resource path.ERR_MODULE_ERRORIf getModule()is anApiModuleand it returned an erroneous result.ERR_NO_FILEModule threw a NoSuchFileExceptionERR_ACCESS_DENIEDModule threw a AccessDeniedExceptionERR_IO_ERRORModule threw an IOExceptionERR_SAX_PARSER_INITFailed to instantiate SAX parser to parse the XML document. ERR_DOC_PARSEUnrecoverable failure trying to parse the XML data ERR_MISSING_PLUGINSOne 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_UNKNOWNAn unknown error caused the document parser to return a nulldocument- Parameters:
uri- file path- Returns:
- Loaded document, or an erroneous result if the document cannot be loaded for any reason.
-
loadStylesheet
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 aIoModulethen this method attempts to use theIoModule.loadString(ResourcePath)to load the stylesheet. If the underlying module is aApiModule, then an erroneous result is returned.Result errors Error code Description ERR_INVALID_PATHThe uricould not be parsed into a resource path.ERR_API_MODULEThe underlying module is an ApiModule, stylesheet loading not supported.ERR_NO_FILEModule threw a NoSuchFileExceptionERR_ACCESS_DENIEDModule threw a AccessDeniedExceptionERR_IO_ERRORModule threw an IOExceptionERR_SYNTAXUnrecoverable 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:
-