mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-06 16:50:39 +00:00
[FEATURE] Comparing versions with the latest API
This commit is contained in:
@@ -22,7 +22,9 @@ public class Configuration {
|
|||||||
public static final String GET_RANDOMS = "http://v3.bdn.parabot.org/api/bot/download/randoms";
|
public static final String GET_RANDOMS = "http://v3.bdn.parabot.org/api/bot/download/randoms";
|
||||||
public static final String DATA_API = "http://bdn.parabot.org/api/v2/data/";
|
public static final String DATA_API = "http://bdn.parabot.org/api/v2/data/";
|
||||||
public static final String ITEM_API = DATA_API + "items/";
|
public static final String ITEM_API = DATA_API + "items/";
|
||||||
|
|
||||||
public static final String COMPARE_VERSION_URL = "http://v3.bdn.parabot.org/api/bot/compare/%s/%s";
|
public static final String COMPARE_VERSION_URL = "http://v3.bdn.parabot.org/api/bot/compare/%s/%s";
|
||||||
|
public static final String COMPARE_CHECKSUM_URL = "http://v3.bdn.parabot.org/api/bot/checksum/%s/%s";
|
||||||
|
|
||||||
public static final Version BOT_VERSION = ProjectProperties.getProjectVersion();
|
public static final Version BOT_VERSION = ProjectProperties.getProjectVersion();
|
||||||
|
|
||||||
|
|||||||
@@ -157,13 +157,9 @@ public class Core {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String result;
|
String result;
|
||||||
if ((result = WebUtil.getContents("http://bdn.parabot.org/api/v2/bot/checksum", "checksum=" + URLEncoder.encode(sb.toString(), "UTF-8"))) != null) {
|
if ((result = WebUtil.getContents(String.format(Configuration.COMPARE_CHECKSUM_URL, "client", currentVersion.get()), "checksum=" + URLEncoder.encode(sb.toString(), "UTF-8"))) != null) {
|
||||||
JSONObject object = (JSONObject) WebUtil.getJsonParser().parse(result);
|
JSONObject object = (JSONObject) WebUtil.getJsonParser().parse(result);
|
||||||
if (!(boolean) object.get("result")) {
|
return Boolean.parseBoolean((String) object.get("result"));
|
||||||
Core.verbose("Latest checksum: " + sb.toString());
|
|
||||||
Core.verbose("Latest checksum: " + object.get("current"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (NoSuchAlgorithmException | ParseException | IOException | URISyntaxException e) {
|
} catch (NoSuchAlgorithmException | ParseException | IOException | URISyntaxException e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user