diff --git a/pom.xml b/pom.xml
index d4b7c89..4cfcb7a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -12,6 +12,7 @@
11
11
+ 1.6.10
@@ -38,6 +39,56 @@
+
+ org.jetbrains.kotlin
+ kotlin-maven-plugin
+ ${kotlin.version}
+
+
+ compile
+ compile
+
+ compile
+
+
+
+ test-compile
+ test-compile
+
+ test-compile
+
+
+
+
+ 1.8
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+
+
+ default-compile
+ none
+
+
+
+ default-testCompile
+ none
+
+
+ java-compile
+ compile
+ compile
+
+
+ java-test-compile
+ test-compile
+ testCompile
+
+
+
@@ -103,5 +154,16 @@
mslinks
1.0.6.2
+
+ org.jetbrains.kotlin
+ kotlin-stdlib-jdk8
+ ${kotlin.version}
+
+
+ org.jetbrains.kotlin
+ kotlin-test
+ ${kotlin.version}
+ test
+
\ No newline at end of file
diff --git a/src/main/java/de/chaos/swlnmngr/Main.java b/src/main/java/de/chaos/swlnmngr/Main.java
index 87d668d..d7ce95a 100644
--- a/src/main/java/de/chaos/swlnmngr/Main.java
+++ b/src/main/java/de/chaos/swlnmngr/Main.java
@@ -12,7 +12,6 @@ import java.util.Arrays;
public class Main {
- @Getter
private static final Logger logger = LogManager.getLogger(Main.class);
@Getter
private static String[] allArgs;
@@ -33,4 +32,8 @@ public class Main {
Router.printRoutes();
}
}
+
+ public static Logger getLogger() {
+ return logger;
+ }
}
diff --git a/src/main/java/de/chaos/swlnmngr/UpdateChecker.java b/src/main/java/de/chaos/swlnmngr/UpdateChecker.java
deleted file mode 100644
index f85ee07..0000000
--- a/src/main/java/de/chaos/swlnmngr/UpdateChecker.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package de.chaos.swlnmngr;
-
-import de.chaos.swlnmngr.config.Config;
-import lombok.experimental.UtilityClass;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.json.JSONArray;
-import org.json.JSONObject;
-import org.json.JSONTokener;
-
-import java.io.IOException;
-import java.net.URI;
-
-@UtilityClass
-public class UpdateChecker {
-
- private static final URI repoUrl = URI.create("https://steamwar.de/devlabs/api/v1/repos/Chaoscaot/SteamwarLinkManager/releases?draft=false&pre-release=" + Config.PRE_RELEASES + "&page=1&limit=1");
-
- public static final String CURRENT_VERSION;
-
- static {
- try {
- CURRENT_VERSION = new String(UpdateChecker.class.getResourceAsStream("/jar.version").readAllBytes());
- } catch (IOException e) {
- Main.getLogger().error("Could not read Version", e);
- System.exit(1);
- throw new SecurityException(e);
- }
- }
-
- public static void checkForUpdates() {
- try (CloseableHttpClient client = HttpClients.createMinimal()) {
- HttpGet get = new HttpGet(repoUrl);
- try (CloseableHttpResponse response = client.execute(get)) {
- JSONArray array = new JSONArray(new JSONTokener(response.getEntity().getContent()));
- JSONObject latestObject = array.getJSONObject(0);
- String latestVersion = latestObject.getString("tag_name");
- if(!latestVersion.equals(CURRENT_VERSION)) {
- Main.getLogger().info("The Running Jar is not the Latest release Version\n\tYour Version: {}\n\tLatest Release Version: {}", CURRENT_VERSION, latestVersion);
- Main.getLogger().info("Download the Latest Jar here: https://steamwar.de/devlabs/Chaoscaot/SteamwarLinkManager/releases");
- }
- }
- } catch (IOException e) {
- Main.getLogger().error("Could not fetch Updates", e);
- }
- }
-}
diff --git a/src/main/java/de/chaos/swlnmngr/UpdateChecker.kt b/src/main/java/de/chaos/swlnmngr/UpdateChecker.kt
new file mode 100644
index 0000000..393734d
--- /dev/null
+++ b/src/main/java/de/chaos/swlnmngr/UpdateChecker.kt
@@ -0,0 +1,75 @@
+package de.chaos.swlnmngr
+
+import de.chaos.swlnmngr.config.Config
+import org.apache.http.client.methods.CloseableHttpResponse
+import org.apache.http.client.methods.HttpGet
+import org.apache.http.impl.client.CloseableHttpClient
+import org.apache.http.impl.client.HttpClients
+import java.io.IOException
+import java.net.URI
+import kotlin.system.exitProcess
+
+class UpdateChecker {
+ companion object {
+ @JvmStatic
+ val repoURL :URI = URI.create("https://steamwar.de/devlabs/repos/Chaoscaot/SteamwarLinkManager/releases")
+
+ @JvmStatic
+ public val CURRENT_VERSION :String;
+
+ init {
+ try {
+ CURRENT_VERSION = String(UpdateChecker::class.java.getResourceAsStream("/jar.version").readAllBytes());
+ } catch (e :IOException) {
+ Main.getLogger().error("Could not read Version", e)
+ exitProcess(1)
+ throw SecurityException(e)
+ }
+ }
+
+ @JvmStatic
+ fun checkForUpdates() {
+ val client :CloseableHttpClient = HttpClients.createMinimal()
+ client.use { client: CloseableHttpClient -> {
+ val get = HttpGet(repoURL);
+ val response :CloseableHttpResponse = client.execute(get)
+ response.use { response: CloseableHttpResponse -> {
+
+ }}
+ }}
+ }
+ }
+}
+
+/*
+private static final URI repoUrl = URI.create("https://steamwar.de/devlabs/api/v1/repos/Chaoscaot/SteamwarLinkManager/releases?draft=false&pre-release=" + Config.PRE_RELEASES + "&page=1&limit=1");
+
+ public static final String CURRENT_VERSION;
+
+ static {
+ try {
+ CURRENT_VERSION = new String(UpdateChecker.class.getResourceAsStream("/jar.version").readAllBytes());
+ } catch (IOException e) {
+ Main.getLogger().error("Could not read Version", e);
+ System.exit(1);
+ throw new SecurityException(e);
+ }
+ }
+
+ public static void checkForUpdates() {
+ try (CloseableHttpClient client = HttpClients.createMinimal()) {
+ HttpGet get = new HttpGet(repoUrl);
+ try (CloseableHttpResponse response = client.execute(get)) {
+ JSONArray array = new JSONArray(new JSONTokener(response.getEntity().getContent()));
+ JSONObject latestObject = array.getJSONObject(0);
+ String latestVersion = latestObject.getString("tag_name");
+ if(!latestVersion.equals(CURRENT_VERSION)) {
+ Main.getLogger().info("The Running Jar is not the Latest release Version\n\tYour Version: {}\n\tLatest Release Version: {}", CURRENT_VERSION, latestVersion);
+ Main.getLogger().info("Download the Latest Jar here: https://steamwar.de/devlabs/Chaoscaot/SteamwarLinkManager/releases");
+ }
+ }
+ } catch (IOException e) {
+ Main.getLogger().error("Could not fetch Updates", e);
+ }
+ }
+ */
\ No newline at end of file
diff --git a/src/main/java/de/chaos/swlnmngr/route/Router.java b/src/main/java/de/chaos/swlnmngr/route/Router.java
deleted file mode 100644
index c00f495..0000000
--- a/src/main/java/de/chaos/swlnmngr/route/Router.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package de.chaos.swlnmngr.route;
-
-import de.chaos.swlnmngr.Main;
-import de.chaos.swlnmngr.route.routes.*;
-
-import java.util.*;
-
-public class Router {
-
- private static final List ROUTES;
-
- static {
- ROUTES = List.of(new InstallRoute(), new UpdateRoute(), new LinkRoute(), new NewRoute());
- }
-
- public static void route(String[] args) {
- for (Route route : ROUTES) {
- if(route.getName().equalsIgnoreCase(args[0])) {
- String[] rArgs = new String[args.length - 1];
- System.arraycopy(args, 1, rArgs, 0, args.length - 1);
- Main.getLogger().info("Running: {}", route.getName());
- if(route.route(rArgs)) {
- System.exit(0);
- } else {
- System.exit(1);
- }
- }
- }
- }
-
- public static void printRoutes() {
- Main.getLogger().info("Available Routes: ");
- Main.getLogger().info("\t{}", ROUTES.stream().map(Route::getName).reduce((s, s2) -> s + ", " + s2).get());
- }
-}
diff --git a/src/main/java/de/chaos/swlnmngr/route/Router.kt b/src/main/java/de/chaos/swlnmngr/route/Router.kt
new file mode 100644
index 0000000..ab295df
--- /dev/null
+++ b/src/main/java/de/chaos/swlnmngr/route/Router.kt
@@ -0,0 +1,35 @@
+package de.chaos.swlnmngr.route
+
+import de.chaos.swlnmngr.Main
+import de.chaos.swlnmngr.route.routes.*
+import org.apache.logging.log4j.Level
+import kotlin.system.exitProcess
+
+class Router {
+
+ companion object {
+ @JvmStatic
+ val ROUTES :List = listOf(InstallRoute(), UpdateRoute(), LinkRoute(), NewRoute())
+
+ @JvmStatic
+ fun route(args: Array) {
+ for (route in ROUTES) {
+ if(route.name.lowercase() == args[0].lowercase()) {
+ val rArgs :Array = Array(args.size - 1) { i: Int -> args[i + 1] }
+ Main.getLogger().info("Running: {}", route.name)
+ if(route.route(rArgs)) {
+ exitProcess(0)
+ } else {
+ exitProcess(1)
+ }
+ }
+ }
+ }
+
+ @JvmStatic
+ fun printRoutes() {
+ Main.getLogger().log(Level.INFO, "Available Routes: ")
+ Main.getLogger().log(Level.INFO, "\t{}", ROUTES.map { route -> route.name }.reduce { acc, s -> "$acc, $s" })
+ }
+ }
+}