mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-03-11 14:20:55 +01:00
Added saveResource method to AddOn save to a specific folder.
This commit is contained in:
parent
92213f20c1
commit
a15b1b2371
@ -137,11 +137,21 @@ public abstract class Addon implements AddonInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves a resource contained in this add-on's jar file.
|
* Saves a resource contained in this add-on's jar file to the addon's data folder.
|
||||||
* @param resourcePath
|
* @param resourcePath in jar file
|
||||||
* @param replace
|
* @param replace - if true, will overwrite previous file
|
||||||
*/
|
*/
|
||||||
public void saveResource(String resourcePath, boolean replace) {
|
public void saveResource(String resourcePath, boolean replace) {
|
||||||
|
saveResource(resourcePath, dataFolder, replace);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves a resource contained in this add-on's jar file to the destination folder.
|
||||||
|
* @param resourcePath in jar file
|
||||||
|
* @param destinationFolder on file system
|
||||||
|
* @param replace - if true, will overwrite previous file
|
||||||
|
*/
|
||||||
|
public void saveResource(String resourcePath, File destinationFolder, boolean replace) {
|
||||||
if (resourcePath == null || resourcePath.equals("")) {
|
if (resourcePath == null || resourcePath.equals("")) {
|
||||||
throw new IllegalArgumentException("ResourcePath cannot be null or empty");
|
throw new IllegalArgumentException("ResourcePath cannot be null or empty");
|
||||||
}
|
}
|
||||||
@ -158,9 +168,9 @@ public abstract class Addon implements AddonInterface {
|
|||||||
jar.close();
|
jar.close();
|
||||||
throw new IllegalArgumentException("The embedded resource '" + resourcePath + "' cannot be found in " + jar.getName());
|
throw new IllegalArgumentException("The embedded resource '" + resourcePath + "' cannot be found in " + jar.getName());
|
||||||
}
|
}
|
||||||
File outFile = new File(dataFolder, resourcePath);
|
File outFile = new File(destinationFolder, resourcePath);
|
||||||
int lastIndex = resourcePath.lastIndexOf('/');
|
int lastIndex = resourcePath.lastIndexOf('/');
|
||||||
File outDir = new File(dataFolder, resourcePath.substring(0, lastIndex >= 0 ? lastIndex : 0));
|
File outDir = new File(destinationFolder, resourcePath.substring(0, lastIndex >= 0 ? lastIndex : 0));
|
||||||
|
|
||||||
if (!outDir.exists()) {
|
if (!outDir.exists()) {
|
||||||
outDir.mkdirs();
|
outDir.mkdirs();
|
||||||
|
Loading…
Reference in New Issue
Block a user