Add support for updating backports correctly
This commit is contained in:
@ -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<URL> 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;
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
Reference in New Issue
Block a user