From 5607aed8810007f5a385f704bd9b12beb15cede0 Mon Sep 17 00:00:00 2001 From: Esoteric Enderman Date: Sun, 3 Nov 2024 14:11:29 +0000 Subject: [PATCH] Add more docs --- .../library/utility/plugin/PluginUtility.kt | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/lib/src/main/kotlin/foundation/esoteric/minecraft/plugins/library/utility/plugin/PluginUtility.kt b/lib/src/main/kotlin/foundation/esoteric/minecraft/plugins/library/utility/plugin/PluginUtility.kt index 0154e9f..e4fb3cf 100644 --- a/lib/src/main/kotlin/foundation/esoteric/minecraft/plugins/library/utility/plugin/PluginUtility.kt +++ b/lib/src/main/kotlin/foundation/esoteric/minecraft/plugins/library/utility/plugin/PluginUtility.kt @@ -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) }