From 9df2758ae66302d80ed2d20b10a8a853d5a42601 Mon Sep 17 00:00:00 2001 From: P0nk Date: Thu, 9 Sep 2021 19:53:44 +0200 Subject: [PATCH] Allow configurable wz directory path with launch property Example: "java -Dwz-path= -jar Cosmic.jar " --- launch.bat | 2 +- src/main/java/provider/wz/WZFiles.java | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/launch.bat b/launch.bat index 903ce475cf..bed9d39b83 100644 --- a/launch.bat +++ b/launch.bat @@ -1,4 +1,4 @@ @echo off @title Cosmic -java -Xmx2048m -jar target\Cosmic.jar +java -Xmx2048m -Dwz-path= -jar target\Cosmic.jar pause \ No newline at end of file diff --git a/src/main/java/provider/wz/WZFiles.java b/src/main/java/provider/wz/WZFiles.java index e5073d0058..f563941118 100644 --- a/src/main/java/provider/wz/WZFiles.java +++ b/src/main/java/provider/wz/WZFiles.java @@ -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"; + } }