mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-07 08:39:12 +00:00
[FEATURE] Added nightly build support
This commit is contained in:
@@ -15,16 +15,19 @@ public class Configuration {
|
|||||||
public static final String GET_SERVER_PROVIDER = "http://bdn.parabot.org/api/get.php?action=server_provider&name=";
|
public static final String GET_SERVER_PROVIDER = "http://bdn.parabot.org/api/get.php?action=server_provider&name=";
|
||||||
public static final String GET_SERVER_PROVIDER_INFO = "http://bdn.parabot.org/api/get.php?action=server_information&name=";
|
public static final String GET_SERVER_PROVIDER_INFO = "http://bdn.parabot.org/api/get.php?action=server_information&name=";
|
||||||
public static final String GET_SERVER_SETTINGS = "http://bdn.parabot.org/api/get.php?action=get_settings";
|
public static final String GET_SERVER_SETTINGS = "http://bdn.parabot.org/api/get.php?action=get_settings";
|
||||||
public static final String GET_BOT_VERSION = "http://v3.bdn.parabot.org/api/bot/list/client?latest=true";
|
public static final String GET_BOT_VERSION = "http://bdn.parabot.org/api/v2/bot/version";
|
||||||
public static final String API_DOWNLOAD_BOT = "http://bdn.parabot.org/api/v2/bot/download/client/";
|
public static final String API_DOWNLOAD_BOT = "http://bdn.parabot.org/api/v2/bot/download/client/";
|
||||||
public static final String DOWNLOAD_BOT = "http://bdn.parabot.org/versions/";
|
public static final String DOWNLOAD_BOT = "http://bdn.parabot.org/versions/";
|
||||||
public static final String REGISTRATION_PAGE = "https://www.parabot.org/community/register/";
|
public static final String REGISTRATION_PAGE = "https://www.parabot.org/community/register/";
|
||||||
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 Version BOT_VERSION = ProjectProperties.getProjectVersion();
|
public static final Version BOT_VERSION = ProjectProperties.getProjectVersion();
|
||||||
|
|
||||||
public static final String BOT_TITLE = "Parabot";
|
public static final String BOT_TITLE = "Parabot";
|
||||||
public static final String BOT_SLOGAN = "The best RuneScape private server bot";
|
public static final String BOT_SLOGAN = "The best RuneScape private server bot";
|
||||||
|
|
||||||
|
public static final String NIGHTLY_APPEND = "nightly=true";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("Duplicates")
|
@SuppressWarnings("Duplicates")
|
||||||
public class Core {
|
public class Core {
|
||||||
public static boolean mDebug;
|
|
||||||
private static boolean debug;
|
private static boolean debug;
|
||||||
private static boolean verbose;
|
private static boolean verbose;
|
||||||
private static boolean dump;
|
private static boolean dump;
|
||||||
@@ -130,6 +130,7 @@ public class Core {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks the version of the bot using a checksum of the jar comparison against checksum given by the website
|
* Checks the version of the bot using a checksum of the jar comparison against checksum given by the website
|
||||||
|
*
|
||||||
* @return <b>true</b> if no new version is found, otherwise <b>false</b>.
|
* @return <b>true</b> if no new version is found, otherwise <b>false</b>.
|
||||||
*/
|
*/
|
||||||
private static boolean checksumValid() {
|
private static boolean checksumValid() {
|
||||||
@@ -173,11 +174,10 @@ public class Core {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Deprecated use #validVersion instead
|
|
||||||
*
|
|
||||||
* Checks the version of the bot using a variable comparison from the bot code and the Parabot website
|
|
||||||
*
|
|
||||||
* @return <b>true</b> if no new version is found, otherwise <b>false</b>.
|
* @return <b>true</b> if no new version is found, otherwise <b>false</b>.
|
||||||
|
* @Deprecated use #validVersion instead
|
||||||
|
* <p>
|
||||||
|
* Checks the version of the bot using a variable comparison from the bot code and the Parabot website
|
||||||
*/
|
*/
|
||||||
private static boolean versionValid() {
|
private static boolean versionValid() {
|
||||||
BufferedReader br = WebUtil.getReader(Configuration.GET_BOT_VERSION);
|
BufferedReader br = WebUtil.getReader(Configuration.GET_BOT_VERSION);
|
||||||
@@ -215,21 +215,20 @@ public class Core {
|
|||||||
* @return True if the current version is equal or higher than the latest version, false if lower than the latest version
|
* @return True if the current version is equal or higher than the latest version, false if lower than the latest version
|
||||||
*/
|
*/
|
||||||
public static boolean validVersion() {
|
public static boolean validVersion() {
|
||||||
BufferedReader br = WebUtil.getReader(Configuration.GET_BOT_VERSION);
|
String url = String.format(Configuration.COMPARE_VERSION_URL, "client", currentVersion.get());
|
||||||
|
|
||||||
|
BufferedReader br = WebUtil.getReader(url);
|
||||||
try {
|
try {
|
||||||
latestVersion = null;
|
latestVersion = null;
|
||||||
if (br != null) {
|
if (br != null) {
|
||||||
JSONObject object = (JSONObject) WebUtil.getJsonParser().parse(br);
|
JSONObject object = (JSONObject) WebUtil.getJsonParser().parse(br);
|
||||||
latestVersion = new Version((String) object.get("version"));
|
boolean latest = Boolean.parseBoolean((String) object.get("result"));
|
||||||
|
if (!latest){
|
||||||
|
Directories.clearCache();
|
||||||
}
|
}
|
||||||
if (latestVersion != null) {
|
return latest;
|
||||||
if (Configuration.BOT_VERSION.compareTo(latestVersion) < 0) {
|
|
||||||
Core.verbose("Our version: " + Configuration.BOT_VERSION.get());
|
|
||||||
Core.verbose("Latest version: " + latestVersion.get());
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
} catch (IOException | ParseException e) {
|
||||||
} catch (NumberFormatException | IOException | ParseException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
@@ -281,7 +280,7 @@ public class Core {
|
|||||||
Core.verbose("Checking for updates...");
|
Core.verbose("Checking for updates...");
|
||||||
validateCache();
|
validateCache();
|
||||||
|
|
||||||
if ((validVersion() && checksumValid()) || (!checksumValid() && currentVersion.compareTo(latestVersion) >= 0)){
|
if (validVersion() && checksumValid()) {
|
||||||
Core.verbose("No updates available.");
|
Core.verbose("No updates available.");
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@@ -289,10 +288,4 @@ public class Core {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void debug(int i) {
|
|
||||||
if(mDebug) {
|
|
||||||
System.out.println("DEBUG: " + i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -22,6 +22,10 @@ public class Version implements Comparable<Version> {
|
|||||||
return this.version;
|
return this.version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isNightly(){
|
||||||
|
return this.version.contains("RC");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(Version that) {
|
public int compareTo(Version that) {
|
||||||
if (that == null) {
|
if (that == null) {
|
||||||
|
|||||||
@@ -8,11 +8,9 @@ import java.io.*;
|
|||||||
import java.net.*;
|
import java.net.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* A WebUtil class fetches data from an URL
|
* A WebUtil class fetches data from an URL
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class WebUtil {
|
public class WebUtil {
|
||||||
|
|
||||||
@@ -223,6 +221,7 @@ public class WebUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Downloads a file on the internet
|
* Downloads a file on the internet
|
||||||
|
*
|
||||||
* @param url
|
* @param url
|
||||||
* @param destination
|
* @param destination
|
||||||
* @param listener
|
* @param listener
|
||||||
@@ -255,6 +254,7 @@ public class WebUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Downloads a file on the internet
|
* Downloads a file on the internet
|
||||||
|
*
|
||||||
* @param url
|
* @param url
|
||||||
* @param destination
|
* @param destination
|
||||||
* @param listener
|
* @param listener
|
||||||
@@ -287,6 +287,7 @@ public class WebUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts file format to url format
|
* Converts file format to url format
|
||||||
|
*
|
||||||
* @param file
|
* @param file
|
||||||
* @return url to file
|
* @return url to file
|
||||||
*/
|
*/
|
||||||
@@ -306,7 +307,8 @@ public class WebUtil {
|
|||||||
return jsonParser;
|
return jsonParser;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static URI appendUri(String uri, String appendQuery) throws URISyntaxException {
|
public static URI appendUri(String uri, String appendQuery) {
|
||||||
|
try {
|
||||||
URI oldUri = new URI(uri);
|
URI oldUri = new URI(uri);
|
||||||
|
|
||||||
String newQuery = oldUri.getQuery();
|
String newQuery = oldUri.getQuery();
|
||||||
@@ -315,8 +317,11 @@ public class WebUtil {
|
|||||||
} else {
|
} else {
|
||||||
newQuery += "&" + appendQuery;
|
newQuery += "&" + appendQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new URI(oldUri.getScheme(), oldUri.getAuthority(),
|
return new URI(oldUri.getScheme(), oldUri.getAuthority(),
|
||||||
oldUri.getPath(), newQuery, oldUri.getFragment());
|
oldUri.getPath(), newQuery, oldUri.getFragment());
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user