Package com.djrapitops.plan.delivery.web
Interface ResourceService
-
public interface ResourceService
Service for making plugin resources customizable by user or Plan API.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
ResourceService.Holder
static class
ResourceService.Position
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addScriptsToResource(java.lang.String pluginName, java.lang.String fileName, ResourceService.Position position, java.lang.String... jsSrcs)
Add javascript to load in an existing html resource.void
addStylesToResource(java.lang.String pluginName, java.lang.String fileName, ResourceService.Position position, java.lang.String... cssSrcs)
Add css to load in an existing html resource.static ResourceService
getInstance()
WebResource
getResource(java.lang.String pluginName, java.lang.String fileName, java.util.function.Supplier<WebResource> source)
Make one of your web resources customizable by user or Plan API.
-
-
-
Method Detail
-
getInstance
static ResourceService getInstance()
-
getResource
WebResource getResource(java.lang.String pluginName, java.lang.String fileName, java.util.function.Supplier<WebResource> source)
Make one of your web resources customizable by user or Plan API.- Parameters:
pluginName
- Name of your plugin (for config purposes)fileName
- Name of the file (for customization)source
- Supplier to use to get the original resource, it is assumed that any text based files are encoded in UTF-8.- Returns:
- Resource of the customized file.
- Throws:
java.lang.IllegalArgumentException
- If pluginName is empty or nulljava.lang.IllegalArgumentException
- If fileName is empty or nulljava.lang.IllegalArgumentException
- If source is null
-
addScriptsToResource
void addScriptsToResource(java.lang.String pluginName, java.lang.String fileName, ResourceService.Position position, java.lang.String... jsSrcs)
Add javascript to load in an existing html resource.Adds
<script src="jsSrc"></script>
or multiple to the resource.- Parameters:
pluginName
- Name of your plugin (for config purposes)fileName
- Name of the .html file being modifiedposition
- Where to place the script tag on the page.jsSrcs
- Source URLs.- Throws:
java.lang.IllegalArgumentException
- If pluginName is empty or nulljava.lang.IllegalArgumentException
- If fileName is null, empty or does not end with .htmljava.lang.IllegalArgumentException
- If position nulljava.lang.IllegalArgumentException
- If jsSrcs is empty or null
-
addStylesToResource
void addStylesToResource(java.lang.String pluginName, java.lang.String fileName, ResourceService.Position position, java.lang.String... cssSrcs)
Add css to load in an existing html resource.Adds
<link href="cssSrc" rel="stylesheet"></link>
or multiple to the resource.- Parameters:
pluginName
- Name of your plugin (for config purposes)fileName
- Name of the .html file being modifiedposition
- Where to place the link tag on the page.cssSrcs
- Source URLs.- Throws:
java.lang.IllegalArgumentException
- If pluginName is empty or nulljava.lang.IllegalArgumentException
- If fileName is null, empty or does not end with .htmljava.lang.IllegalArgumentException
- If position nulljava.lang.IllegalArgumentException
- If cssSrcs is empty or null
-
-