diff --git a/build.gradle b/build.gradle index 3a72010..dec555e 100644 --- a/build.gradle +++ b/build.gradle @@ -72,7 +72,7 @@ def gitInfo(String key) { gitInfoCached = [ hash : ['git', 'log', "--format=%h", '-n', '1'].execute().text.trim(), fullHash: ['git', 'log', "--format=%H", '-n', '1'].execute().text.trim(), - branch : ['git', 'symbolic-ref', '--short', 'HEAD'].execute().text.trim(), + branch : System.getenv("CI_BUILD_REF_NAME") ?: ['git', 'symbolic-ref', '--short', 'HEAD'].execute().text.trim(), message : ['git', 'log', "--format=%B", '-n', '1'].execute().text.trim() ] } else { @@ -103,8 +103,9 @@ tasks.packageUniversal { 'KCauldron-Git-Branch' : gitInfo('branch'), 'KCauldron-Git-Hash' : gitInfo('fullHash'), 'KCauldron-Version' : project.version, + 'KCauldron-Channel' : project.name, 'Implementation-Vendor' : 'Prototik', - 'Implementation-Title' : 'KCauldron', + 'Implementation-Title' : project.name, 'Implementation-Version': project.version, 'Forge-Version' : '10.13.3.1420', 'Specification-Vendor' : 'Bukkit Team', diff --git a/patches/net/minecraft/network/rcon/RConThreadClient.java.patch b/patches/net/minecraft/network/rcon/RConThreadClient.java.patch index 9be0228..7c6dad9 100644 --- a/patches/net/minecraft/network/rcon/RConThreadClient.java.patch +++ b/patches/net/minecraft/network/rcon/RConThreadClient.java.patch @@ -8,10 +8,9 @@ + try { - try -- { -- if (!this.running) + while (true) -+ { + { +- if (!this.running) + if (!this.running || clientSocket == null) { break; @@ -28,12 +27,11 @@ return; } -@@ -109,27 +110,24 @@ - continue; +@@ -110,26 +111,23 @@ } } -+ } } ++ } catch (SocketTimeoutException sockettimeoutexception) { - break; diff --git a/src/main/java/kcauldron/KCauldron.java b/src/main/java/kcauldron/KCauldron.java index 6388e1a..1b0eeea 100644 --- a/src/main/java/kcauldron/KCauldron.java +++ b/src/main/java/kcauldron/KCauldron.java @@ -7,11 +7,12 @@ import java.util.Enumeration; import java.util.Properties; public class KCauldron { - private static String sCurrentVersion; - - public static String getCurrentVersion() { - if (sCurrentVersion != null) - return sCurrentVersion; + private static boolean sManifestParsed = false; + + private static void parseManifest() { + if (sManifestParsed) return; + sManifestParsed = true; + try { Enumeration resources = KCauldron.class.getClassLoader() .getResources("META-INF/MANIFEST.MF"); @@ -25,23 +26,47 @@ public class KCauldron { String jarFilePath = path.substring(path.indexOf(":") + 1, path.indexOf("!")); jarFilePath = URLDecoder.decode(jarFilePath, "UTF-8"); sServerLocation = new File(jarFilePath); - return sCurrentVersion = version; + + sCurrentVersion = version; + sBranch = manifest.getProperty("KCauldron-Branch"); + sChannel = manifest.getProperty("KCauldron-Channel"); } manifest.clear(); } } catch (Exception e) { e.printStackTrace(); } - return sCurrentVersion = "UNKNOWN"; + + } + + private static String sCurrentVersion; + + public static String getCurrentVersion() { + parseManifest(); + return sCurrentVersion; } private static File sServerLocation; public static File getServerLocation() { - getCurrentVersion(); + parseManifest(); return sServerLocation; } + private static String sBranch; + + public static String getBranch() { + parseManifest(); + return sBranch; + } + + private static String sChannel; + + public static String getChannel() { + parseManifest(); + return sChannel; + } + public static File sNewServerLocation; public static String sNewServerVersion; public static boolean sUpdateInProgress; diff --git a/src/main/java/kcauldron/updater/KCauldronUpdater.java b/src/main/java/kcauldron/updater/KCauldronUpdater.java index d8b5186..bdfa034 100644 --- a/src/main/java/kcauldron/updater/KCauldronUpdater.java +++ b/src/main/java/kcauldron/updater/KCauldronUpdater.java @@ -38,7 +38,7 @@ public class KCauldronUpdater implements Runnable { + version + ") is up to date"); } } - + @Override public void error(Throwable t) { super.error(t); @@ -117,8 +117,9 @@ public class KCauldronUpdater implements Runnable { } HttpUriRequest request = RequestBuilder .get() - .setUri("https://prok.pw/repo/pw/prok/KCauldron/" - + mVersion + "/" + filename) + .setUri("https://prok.pw/repo/pw/prok/" + + KCauldron.getChannel() + "/" + mVersion + "/" + + filename) .addParameter("hostname", server.getHostname()) .addParameter("port", "" + server.getPort()).build(); HttpResponse response = HttpClientBuilder.create() diff --git a/src/main/java/kcauldron/updater/KVersionRetriever.java b/src/main/java/kcauldron/updater/KVersionRetriever.java index c0b98d4..8302423 100644 --- a/src/main/java/kcauldron/updater/KVersionRetriever.java +++ b/src/main/java/kcauldron/updater/KVersionRetriever.java @@ -71,8 +71,10 @@ public class KVersionRetriever implements Runnable, UncaughtExceptionHandler { if (DEBUG) sLogger.info("Requesting for new version..."); try { - HttpUriRequest request = RequestBuilder.get() - .setUri("https://prok.pw/version/pw.prok/KCauldron") + HttpUriRequest request = RequestBuilder + .get() + .setUri("https://prok.pw/version/pw.prok/" + + KCauldron.getChannel()) .addParameter("hostname", sServer.getHostname()) .addParameter("port", "" + sServer.getPort()).build(); HttpResponse response = HttpClientBuilder.create()