3
0

Add support for updating backports correctly

This commit is contained in:
Prototik 2015-06-03 21:50:46 +07:00
parent 5a9c5f6f72
commit 27d13cce59
5 changed files with 48 additions and 21 deletions

View File

@ -72,7 +72,7 @@ def gitInfo(String key) {
gitInfoCached = [ gitInfoCached = [
hash : ['git', 'log', "--format=%h", '-n', '1'].execute().text.trim(), hash : ['git', 'log', "--format=%h", '-n', '1'].execute().text.trim(),
fullHash: ['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() message : ['git', 'log', "--format=%B", '-n', '1'].execute().text.trim()
] ]
} else { } else {
@ -103,8 +103,9 @@ tasks.packageUniversal {
'KCauldron-Git-Branch' : gitInfo('branch'), 'KCauldron-Git-Branch' : gitInfo('branch'),
'KCauldron-Git-Hash' : gitInfo('fullHash'), 'KCauldron-Git-Hash' : gitInfo('fullHash'),
'KCauldron-Version' : project.version, 'KCauldron-Version' : project.version,
'KCauldron-Channel' : project.name,
'Implementation-Vendor' : 'Prototik', 'Implementation-Vendor' : 'Prototik',
'Implementation-Title' : 'KCauldron', 'Implementation-Title' : project.name,
'Implementation-Version': project.version, 'Implementation-Version': project.version,
'Forge-Version' : '10.13.3.1420', 'Forge-Version' : '10.13.3.1420',
'Specification-Vendor' : 'Bukkit Team', 'Specification-Vendor' : 'Bukkit Team',

View File

@ -8,10 +8,9 @@
+ try + try
{ {
- try - try
- {
- if (!this.running)
+ while (true) + while (true)
+ { {
- if (!this.running)
+ if (!this.running || clientSocket == null) + if (!this.running || clientSocket == null)
{ {
break; break;
@ -28,12 +27,11 @@
return; return;
} }
@@ -109,27 +110,24 @@ @@ -110,26 +111,23 @@
continue;
} }
} }
+ }
} }
+ }
catch (SocketTimeoutException sockettimeoutexception) catch (SocketTimeoutException sockettimeoutexception)
{ {
- break; - break;

View File

@ -7,11 +7,12 @@ import java.util.Enumeration;
import java.util.Properties; import java.util.Properties;
public class KCauldron { public class KCauldron {
private static String sCurrentVersion; private static boolean sManifestParsed = false;
public static String getCurrentVersion() { private static void parseManifest() {
if (sCurrentVersion != null) if (sManifestParsed) return;
return sCurrentVersion; sManifestParsed = true;
try { try {
Enumeration<URL> resources = KCauldron.class.getClassLoader() Enumeration<URL> resources = KCauldron.class.getClassLoader()
.getResources("META-INF/MANIFEST.MF"); .getResources("META-INF/MANIFEST.MF");
@ -25,23 +26,47 @@ public class KCauldron {
String jarFilePath = path.substring(path.indexOf(":") + 1, path.indexOf("!")); String jarFilePath = path.substring(path.indexOf(":") + 1, path.indexOf("!"));
jarFilePath = URLDecoder.decode(jarFilePath, "UTF-8"); jarFilePath = URLDecoder.decode(jarFilePath, "UTF-8");
sServerLocation = new File(jarFilePath); sServerLocation = new File(jarFilePath);
return sCurrentVersion = version;
sCurrentVersion = version;
sBranch = manifest.getProperty("KCauldron-Branch");
sChannel = manifest.getProperty("KCauldron-Channel");
} }
manifest.clear(); manifest.clear();
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
return sCurrentVersion = "UNKNOWN";
}
private static String sCurrentVersion;
public static String getCurrentVersion() {
parseManifest();
return sCurrentVersion;
} }
private static File sServerLocation; private static File sServerLocation;
public static File getServerLocation() { public static File getServerLocation() {
getCurrentVersion(); parseManifest();
return sServerLocation; 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 File sNewServerLocation;
public static String sNewServerVersion; public static String sNewServerVersion;
public static boolean sUpdateInProgress; public static boolean sUpdateInProgress;

View File

@ -38,7 +38,7 @@ public class KCauldronUpdater implements Runnable {
+ version + ") is up to date"); + version + ") is up to date");
} }
} }
@Override @Override
public void error(Throwable t) { public void error(Throwable t) {
super.error(t); super.error(t);
@ -117,8 +117,9 @@ public class KCauldronUpdater implements Runnable {
} }
HttpUriRequest request = RequestBuilder HttpUriRequest request = RequestBuilder
.get() .get()
.setUri("https://prok.pw/repo/pw/prok/KCauldron/" .setUri("https://prok.pw/repo/pw/prok/"
+ mVersion + "/" + filename) + KCauldron.getChannel() + "/" + mVersion + "/"
+ filename)
.addParameter("hostname", server.getHostname()) .addParameter("hostname", server.getHostname())
.addParameter("port", "" + server.getPort()).build(); .addParameter("port", "" + server.getPort()).build();
HttpResponse response = HttpClientBuilder.create() HttpResponse response = HttpClientBuilder.create()

View File

@ -71,8 +71,10 @@ public class KVersionRetriever implements Runnable, UncaughtExceptionHandler {
if (DEBUG) if (DEBUG)
sLogger.info("Requesting for new version..."); sLogger.info("Requesting for new version...");
try { try {
HttpUriRequest request = RequestBuilder.get() HttpUriRequest request = RequestBuilder
.setUri("https://prok.pw/version/pw.prok/KCauldron") .get()
.setUri("https://prok.pw/version/pw.prok/"
+ KCauldron.getChannel())
.addParameter("hostname", sServer.getHostname()) .addParameter("hostname", sServer.getHostname())
.addParameter("port", "" + sServer.getPort()).build(); .addParameter("port", "" + sServer.getPort()).build();
HttpResponse response = HttpClientBuilder.create() HttpResponse response = HttpClientBuilder.create()