Package com.ranull.graves.util
Class ResourceUtil
java.lang.Object
com.ranull.graves.util.ResourceUtil
Utility class for copying resources from a plugin's JAR file to the file system.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
copyResources
(String inputPath, String outputPath, boolean overwrite, org.bukkit.plugin.java.JavaPlugin plugin) Copies resources from the plugin's JAR file to the specified output path.static void
copyResources
(String inputPath, String outputPath, org.bukkit.plugin.java.JavaPlugin plugin) Copies resources from the plugin's JAR file to the specified output path.private static boolean
createDirectories
(File file) Creates the necessary directories for the specified file.private static String
formatString
(String string) Formats a file path string to use the system's file separator.private static Map
<String, InputStream> getResources
(String path, org.bukkit.plugin.java.JavaPlugin plugin) Retrieves resources from the plugin's JAR file at the specified path.private static void
saveResources
(Map<String, InputStream> inputStreamMap, String inputPath, String outputPath, boolean overwrite) Saves the retrieved resources to the specified output path.
-
Constructor Details
-
ResourceUtil
public ResourceUtil()
-
-
Method Details
-
copyResources
public static void copyResources(String inputPath, String outputPath, org.bukkit.plugin.java.JavaPlugin plugin) Copies resources from the plugin's JAR file to the specified output path.- Parameters:
inputPath
- The path inside the JAR file to copy from.outputPath
- The path on the file system to copy to.plugin
- The plugin instance.
-
copyResources
public static void copyResources(String inputPath, String outputPath, boolean overwrite, org.bukkit.plugin.java.JavaPlugin plugin) Copies resources from the plugin's JAR file to the specified output path.- Parameters:
inputPath
- The path inside the JAR file to copy from.outputPath
- The path on the file system to copy to.overwrite
- Whether to overwrite existing files.plugin
- The plugin instance.
-
getResources
private static Map<String,InputStream> getResources(String path, org.bukkit.plugin.java.JavaPlugin plugin) Retrieves resources from the plugin's JAR file at the specified path.- Parameters:
path
- The path inside the JAR file.plugin
- The plugin instance.- Returns:
- A map of resource paths to their input streams.
-
saveResources
private static void saveResources(Map<String, InputStream> inputStreamMap, String inputPath, String outputPath, boolean overwrite) Saves the retrieved resources to the specified output path.- Parameters:
inputStreamMap
- A map of resource paths to their input streams.inputPath
- The path inside the JAR file.outputPath
- The path on the file system to copy to.overwrite
- Whether to overwrite existing files.
-
createDirectories
Creates the necessary directories for the specified file.- Parameters:
file
- The file for which to create directories.- Returns:
- True if the directories were created successfully, false otherwise.
-
formatString
Formats a file path string to use the system's file separator.- Parameters:
string
- The string to format.- Returns:
- The formatted string.
-