1
0

Commits vergleichen

..

1 Commits

Autor SHA1 Nachricht Datum
Chaos
d8227a18c3 Bump Version 2022-01-11 21:54:49 +01:00
7 geänderte Dateien mit 85 neuen und 196 gelöschten Zeilen

64
pom.xml
Datei anzeigen

@ -6,13 +6,12 @@
<groupId>de.chaos</groupId> <groupId>de.chaos</groupId>
<artifactId>swlnmngr</artifactId> <artifactId>swlnmngr</artifactId>
<version>0.1.3</version> <version>0.2.0</version>
<name>SteamWarLinkManager</name> <name>SteamWarLinkManager</name>
<properties> <properties>
<maven.compiler.source>11</maven.compiler.source> <maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target> <maven.compiler.target>11</maven.compiler.target>
<kotlin.version>1.6.10</kotlin.version>
</properties> </properties>
<build> <build>
@ -39,56 +38,6 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<configuration>
<jvmTarget>1.8</jvmTarget>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<!-- Replacing default-compile as it is treated specially by maven -->
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
<!-- Replacing default-testCompile as it is treated specially by maven -->
<execution>
<id>default-testCompile</id>
<phase>none</phase>
</execution>
<execution>
<id>java-compile</id>
<phase>compile</phase>
<goals> <goal>compile</goal> </goals>
</execution>
<execution>
<id>java-test-compile</id>
<phase>test-compile</phase>
<goals> <goal>testCompile</goal> </goals>
</execution>
</executions>
</plugin>
</plugins> </plugins>
<resources> <resources>
<resource> <resource>
@ -148,16 +97,5 @@
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>
<version>2.11.0</version> <version>2.11.0</version>
</dependency> </dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test</artifactId>
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>

Datei anzeigen

@ -0,0 +1,49 @@
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 org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONTokener;
import java.io.IOException;
import java.net.URI;
public class UpdateChecker {
private 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);
}
}
}

Datei anzeigen

@ -1,82 +0,0 @@
package de.chaos.swlnmngr
import org.apache.http.client.methods.HttpGet
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/Chaoscaot/SteamwarLinkManager/releases/latest")
@JvmStatic
val download = URI.create("$repoURL/download/")
@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 = HttpClients.custom().disableRedirectHandling().build()
Main.getLogger().debug("Checking for Updates...")
val get = HttpGet(repoURL)
Main.getLogger().debug(get)
val response = client.execute(get)
Main.getLogger().debug(response.statusLine.toString())
val latest = response.getFirstHeader("Location").value.replaceFirst(".*/".toRegex(), "")
if (latest != CURRENT_VERSION) {
Main.getLogger().info("The Running Jar is not the Latest release Version\n\tYour Version: {}\n\tLatest Release Version: {}", CURRENT_VERSION, latest)
Main.getLogger().info("Download the Latest Jar here: https://steamwar.de/devlabs/Chaoscaot/SteamwarLinkManager/releases/latest")
}
response.close()
client.close()
}
}
}
/*
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);
}
}
*/

Datei anzeigen

@ -1,7 +1,6 @@
package de.chaos.swlnmngr.config; package de.chaos.swlnmngr.config;
import de.chaos.swlnmngr.Main; import de.chaos.swlnmngr.Main;
import de.chaos.swlnmngr.route.Router;
import org.apache.commons.cli.*; import org.apache.commons.cli.*;
import java.io.File; import java.io.File;
@ -24,7 +23,6 @@ public class CLIConfig {
options.addOption(new Option("c", "config", true, "Use another Config File")); options.addOption(new Option("c", "config", true, "Use another Config File"));
options.addOption(new Option("i", "installdir", true, "Use other Install Dir")); options.addOption(new Option("i", "installdir", true, "Use other Install Dir"));
options.addOption(new Option("u", "update-checker", false, "Enable the Auto-Update Checker")); options.addOption(new Option("u", "update-checker", false, "Enable the Auto-Update Checker"));
options.addOption(new Option(null, "update-the-fucking-jar-please", false, "Self Describing"));
CommandLine cli = null; CommandLine cli = null;
CommandLineParser parser = new DefaultParser(); CommandLineParser parser = new DefaultParser();
@ -69,8 +67,5 @@ public class CLIConfig {
} else { } else {
CONFIG = new File(INSTALL_DIR, "config.json"); CONFIG = new File(INSTALL_DIR, "config.json");
} }
if(cli.hasOption("update-the-fucking-jar-please")) {
Router.route(new String[] {"update-jar"});
}
} }
} }

Datei anzeigen

@ -0,0 +1,35 @@
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<Route> 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());
}
}

Datei anzeigen

@ -1,35 +0,0 @@
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<Route> = listOf(InstallRoute(), UpdateRoute(), LinkRoute(), NewRoute(), UpdateJarRoute())
@JvmStatic
fun route(args: Array<String>) {
for (route in ROUTES) {
if(route.name.lowercase() == args[0].lowercase()) {
val rArgs :Array<String> = 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" })
}
}
}

Datei anzeigen

@ -1,11 +0,0 @@
package de.chaos.swlnmngr.route.routes
class UpdateJarRoute :Route {
override fun getName(): String {
return "update-jar"
}
override fun route(args: Array<out String>?): Boolean {
TODO("Not yet implemented")
}
}