diff --git a/pom.xml b/pom.xml
index ec3e31b..c424a42 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
de.chaos
swlnmngr
- 0.1.1
+ 0.1.2
SteamWarLinkManager
diff --git a/src/main/java/de/chaos/swlnmngr/config/CLIConfig.java b/src/main/java/de/chaos/swlnmngr/config/CLIConfig.java
index c0b95c2..507b480 100644
--- a/src/main/java/de/chaos/swlnmngr/config/CLIConfig.java
+++ b/src/main/java/de/chaos/swlnmngr/config/CLIConfig.java
@@ -44,7 +44,7 @@ public class CLIConfig {
if(cli.hasOption("i")) {
INSTALL_DIR = new File(cli.getOptionValue("i"));
} else {
- INSTALL_DIR = new File("~/.swlnmngr/");
+ INSTALL_DIR = new File(System.getProperty("user.home"), ".swlnmngr/").toPath().normalize().toFile();
}
if(cli.hasOption("c")) {
CONFIG = new File(cli.getOptionValue("c"));
diff --git a/src/main/java/de/chaos/swlnmngr/config/Config.java b/src/main/java/de/chaos/swlnmngr/config/Config.java
index 16ce300..8c94446 100644
--- a/src/main/java/de/chaos/swlnmngr/config/Config.java
+++ b/src/main/java/de/chaos/swlnmngr/config/Config.java
@@ -1,7 +1,6 @@
package de.chaos.swlnmngr.config;
import de.chaos.swlnmngr.Main;
-import org.apache.logging.log4j.Level;
import org.json.JSONObject;
import org.json.JSONTokener;
@@ -9,12 +8,11 @@ import java.io.File;
import java.io.FileInputStream;
import java.net.URI;
import java.net.URISyntaxException;
-import java.nio.file.Files;
-import java.nio.file.StandardOpenOption;
+import java.util.Objects;
public class Config {
- private static final File CONFIG_FILE = new File(CLIConfig.INSTALL_DIR, "config.json");
+ private static File CONFIG_FILE = new File(CLIConfig.INSTALL_DIR, "config.json");
public static final File PROJECT_PATH;
public static final File LIB_PATH;
@@ -29,13 +27,10 @@ public class Config {
JSONObject config = null;
try {
if(!CONFIG_FILE.exists()) {
- if(CONFIG_FILE.getParentFile().mkdir()) {
- Main.getLogger().log(Level.DEBUG, "Created Config Folder");
- }
- Files.write(CONFIG_FILE.toPath(), Config.class.getResourceAsStream("/default_config.json").readAllBytes(), StandardOpenOption.CREATE_NEW);
+ config = new JSONObject(new JSONTokener(Objects.requireNonNull(Config.class.getResourceAsStream("/default_config.json"))));
+ } else {
+ config = new JSONObject(new JSONTokener(new FileInputStream(CONFIG_FILE)));
}
-
- config = new JSONObject(new JSONTokener(new FileInputStream(CONFIG_FILE)));
} catch (Exception e) {
Main.getLogger().fatal("Could not load Config", e);
System.exit(1);
@@ -53,8 +48,7 @@ public class Config {
throw new SecurityException(e);
}
- JSONObject credentials = config.getJSONObject("credentials");
- USERNAME = credentials.getString("username");
- PASSWORD = credentials.getString("password");
+ USERNAME = config.getString("username");
+ PASSWORD = config.getString("password");
}
}
diff --git a/src/main/java/de/chaos/swlnmngr/route/routes/InstallRoute.java b/src/main/java/de/chaos/swlnmngr/route/routes/InstallRoute.java
index 57adbb1..613a80e 100644
--- a/src/main/java/de/chaos/swlnmngr/route/routes/InstallRoute.java
+++ b/src/main/java/de/chaos/swlnmngr/route/routes/InstallRoute.java
@@ -27,13 +27,19 @@ public class InstallRoute implements Route {
public boolean route(String[] args) {
File installDir = CLIConfig.INSTALL_DIR;
if(!installDir.exists()) {
- installDir.mkdir();
+ try {
+ Files.createDirectories(CLIConfig.INSTALL_DIR.toPath());
+ } catch (IOException e) {
+ Main.getLogger().error("Could not create Install Directory", e);
+ return false;
+ }
}
for (String defaultFile : defaultFiles) {
String normalName = defaultFile.replace("default_", "");
try {
Files.copy(Objects.requireNonNull(InstallRoute.class.getResourceAsStream("/" + defaultFile)), new File(CLIConfig.INSTALL_DIR, normalName).toPath(), StandardCopyOption.REPLACE_EXISTING);
+ new File(CLIConfig.INSTALL_DIR, normalName).setExecutable(true, true);
} catch (IOException e) {
Main.getLogger().error("Could not create File", e);
return false;
diff --git a/src/main/resources/default_swlnmngr.bat b/src/main/resources/default_swlnmngr.bat
index 2a53abe..8f3e2ed 100644
--- a/src/main/resources/default_swlnmngr.bat
+++ b/src/main/resources/default_swlnmngr.bat
@@ -1 +1 @@
-java -jar ./SteamWarLinkManager.jar
\ No newline at end of file
+java -jar ./SteamWarLinkManager.jar %*
\ No newline at end of file
diff --git a/src/main/resources/default_swlnmngr.sh b/src/main/resources/default_swlnmngr.sh
index efbd049..20d6e03 100644
--- a/src/main/resources/default_swlnmngr.sh
+++ b/src/main/resources/default_swlnmngr.sh
@@ -1,2 +1,2 @@
#!/bin/bash
-java -jar ./SteamWarLinkManager.jar
\ No newline at end of file
+java -jar ./SteamWarLinkManager.jar $@
\ No newline at end of file