Skip to content

Commit

Permalink
Add more docs
Browse files Browse the repository at this point in the history
  • Loading branch information
EsotericEnderman committed Nov 3, 2024
1 parent a126244 commit 5607aed
Showing 1 changed file with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,40 @@ package foundation.esoteric.minecraft.plugins.library.utility.plugin

import foundation.esoteric.utility.resource.saveResources
import org.bukkit.plugin.Plugin
import org.bukkit.plugin.java.JavaPlugin
import java.io.File
import java.nio.file.Path

/**
* Saves the raw contents of any resource embedded with a plugin's .jar
* file assuming it can be found using getResource(String).
*
* 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
* @author Esoteric Enderman
*/
fun Plugin.saveResource(resourcePath: Path, replace: Boolean = true) {
saveResource(resourcePath.toString(), replace)
}

/**
* Saves the raw contents of any resource embedded with a plugin's .jar
* file assuming it can be found using getResource(String).
*
* 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
* @author Esoteric Enderman
*/
fun Plugin.saveResource(resourcePath: String) {
saveResource(resourcePath, true)
}
Expand Down

0 comments on commit 5607aed

Please sign in to comment.