Allow configurable wz directory path with launch property

Example: "java -Dwz-path=<my-custom-path> -jar Cosmic.jar "
This commit is contained in:
P0nk
2021-09-09 19:53:44 +02:00
parent 0196d69780
commit 9df2758ae6
2 changed files with 13 additions and 2 deletions

View File

@@ -1,4 +1,4 @@
@echo off
@title Cosmic
java -Xmx2048m -jar target\Cosmic.jar
java -Xmx2048m -Dwz-path= -jar target\Cosmic.jar
pause

View File

@@ -17,7 +17,7 @@ public enum WZFiles {
SOUND("Sound"),
UI("UI");
public static final String DIRECTORY = "wz";
public static final String DIRECTORY = getWzDirectory();
private final String fileName;
@@ -32,4 +32,15 @@ public enum WZFiles {
public String getFilePath() {
return getFile().getPath();
}
private static String getWzDirectory() {
// Either provide a custom directory path through the "wz-path" property when launching the .jar,
// or don't provide one to use the default "wz" directory
String propertyPath = System.getProperty("wz-path");
if (propertyPath != null && new File(propertyPath).isDirectory()) {
return propertyPath;
}
return "wz";
}
}