Skip to content

Commit

Permalink
Complete plugin utility docs
Browse files Browse the repository at this point in the history
  • Loading branch information
esotericenderman committed Nov 3, 2024
1 parent 95b250f commit 3c82914
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import java.nio.file.Path
*
* The resource is saved into the plugin's data folder using the same
* hierarchy as the .jar file (subdirectories are preserved).
*
* @param resourcePath the embedded resource path to look for within the plugin's .jar file. (No preceding slash).
* @param replace if true, the embedded resource will overwrite the contents of an existing file.
* @throws IllegalArgumentException if the resource path is null, empty, or points to a nonexistent resource.
* @see Plugin.saveResource
* @see Plugin.saveResources
* @see Plugin.getResource
* @see Plugin.getDataFolder
* @see Plugin.getDataPath
* @author Esoteric Enderman
Expand All @@ -31,11 +31,11 @@ fun Plugin.saveResource(resourcePath: Path, replace: Boolean = true) {
*
* The resource is saved into the plugin's data folder using the same
* hierarchy as the .jar file (subdirectories are preserved).
*
* @param resourcePath the embedded resource path to look for within the plugin's .jar file. (No preceding slash).
* @throws IllegalArgumentException if the resource path is null, empty, or points to a nonexistent resource.
* @see Plugin.saveResource
* @see Plugin.saveResources
* @see Plugin.getResource
* @see Plugin.getDataFolder
* @see Plugin.getDataPath
* @author Esoteric Enderman
Expand All @@ -44,6 +44,20 @@ fun Plugin.saveResource(resourcePath: String) {
saveResource(resourcePath, true)
}

/**
* Saves the raw contents of any resource folder embedded with a plugin's .jar.
*
* The resources are saved into the plugin's data folder using the same
* hierarchy as the .jar file (subdirectories are preserved).
* @param resourceFolderPath the embedded resource path to look for within the plugin's .jar file. (No preceding slash).
* @return The saved folder `File`.
* @throws IllegalArgumentException if the resource path is null, empty, or points to a nonexistent resource folder.
* @see Plugin.saveResource
* @see Plugin.getResource
* @see Plugin.getDataFolder
* @see Plugin.getDataPath
* @author Esoteric Enderman
*/
fun Plugin.saveResources(resourceFolderPath: Path): File {
val subFolder = File(dataFolder, resourceFolderPath.toString())
return resourceFolderPath.saveResources(subFolder)
Expand Down

0 comments on commit 3c82914

Please sign in to comment.