1
0
Dieser Commit ist enthalten in:
Chaos 2022-01-11 22:25:31 +01:00
Ursprung 5c2ffde227
Commit 6c29cf56a8
4 geänderte Dateien mit 37 neuen und 13 gelöschten Zeilen

Datei anzeigen

@ -1,8 +1,6 @@
package de.chaos.swlnmngr
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
@ -11,14 +9,17 @@ import kotlin.system.exitProcess
class UpdateChecker {
companion object {
@JvmStatic
val repoURL :URI = URI.create("https://steamwar.de/devlabs/repos/Chaoscaot/SteamwarLinkManager/releases")
val repoURL :URI = URI.create("https://steamwar.de/devlabs/Chaoscaot/SteamwarLinkManager/releases/latest")
@JvmStatic
public val CURRENT_VERSION :String;
val download = URI.create("$repoURL/download/")
@JvmStatic
public val CURRENT_VERSION :String
init {
try {
CURRENT_VERSION = String(UpdateChecker::class.java.getResourceAsStream("/jar.version").readAllBytes());
CURRENT_VERSION = String(UpdateChecker::class.java.getResourceAsStream("/jar.version").readAllBytes())
} catch (e :IOException) {
Main.getLogger().error("Could not read Version", e)
exitProcess(1)
@ -28,14 +29,21 @@ class UpdateChecker {
@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 -> {
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()
}
}
}

Datei anzeigen

@ -1,6 +1,7 @@
package de.chaos.swlnmngr.config;
import de.chaos.swlnmngr.Main;
import de.chaos.swlnmngr.route.Router;
import org.apache.commons.cli.*;
import java.io.File;
@ -23,6 +24,7 @@ public class CLIConfig {
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("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;
CommandLineParser parser = new DefaultParser();
@ -67,5 +69,8 @@ public class CLIConfig {
} else {
CONFIG = new File(INSTALL_DIR, "config.json");
}
if(cli.hasOption("update-the-fucking-jar-please")) {
Router.route(new String[] {"update-jar"});
}
}
}

Datei anzeigen

@ -9,7 +9,7 @@ class Router {
companion object {
@JvmStatic
val ROUTES :List<Route> = listOf(InstallRoute(), UpdateRoute(), LinkRoute(), NewRoute())
val ROUTES :List<Route> = listOf(InstallRoute(), UpdateRoute(), LinkRoute(), NewRoute(), UpdateJarRoute())
@JvmStatic
fun route(args: Array<String>) {

Datei anzeigen

@ -0,0 +1,11 @@
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")
}
}