mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-05 16:49:41 +00:00
+2
-1
@@ -118,4 +118,5 @@ buildNumber.properties
|
|||||||
|
|
||||||
### Custom
|
### Custom
|
||||||
parabotv2
|
parabotv2
|
||||||
releases
|
releases
|
||||||
|
._*
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Parabot
|
# Parabot
|
||||||
|
|
||||||
Parabot V2.2.
|
Parabot V2.4
|
||||||
|
|
||||||
#### Website
|
#### Website
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ If you've an issues regarding the bot itself, please report them [here](https://
|
|||||||
Parabot supports Maven as of September 2015. All information is included in the POM.xml.
|
Parabot supports Maven as of September 2015. All information is included in the POM.xml.
|
||||||
The API that is supported by Parabot is also published on a Maven repository.
|
The API that is supported by Parabot is also published on a Maven repository.
|
||||||
If you'd like to have either or both the client and the API in your project, use the following repository and dependecy tags:
|
If you'd like to have either or both the client and the API in your project, use the following repository and dependecy tags:
|
||||||
~```
|
```
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>git-parabot</id>
|
<id>git-parabot</id>
|
||||||
@@ -38,5 +38,5 @@ If you'd like to have either or both the client and the API in your project, use
|
|||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
```~
|
```
|
||||||
**For the latest versions of our dependencies, please check our examples on [the Maven Repository](https://github.com/Parabot/Maven-Repository/tree/master/examples)**
|
**For the latest versions of our dependencies, please check our examples on [the Maven Repository](https://github.com/Parabot/Maven-Repository/tree/master/examples)**
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>org.parabot</groupId>
|
<groupId>org.parabot</groupId>
|
||||||
<artifactId>client</artifactId>
|
<artifactId>client</artifactId>
|
||||||
<version>2.4.1</version>
|
<version>2.4.1.1</version>
|
||||||
|
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public final class Landing {
|
|||||||
"Please download the newest version of Parabot at "
|
"Please download the newest version of Parabot at "
|
||||||
+ Configuration.DOWNLOAD_BOT,
|
+ Configuration.DOWNLOAD_BOT,
|
||||||
JOptionPane.INFORMATION_MESSAGE);
|
JOptionPane.INFORMATION_MESSAGE);
|
||||||
URI uri = URI.create(Configuration.DOWNLOAD_BOT);
|
URI uri = URI.create(Configuration.API_DOWNLOAD_BOT);
|
||||||
try {
|
try {
|
||||||
Desktop.getDesktop().browse(uri);
|
Desktop.getDesktop().browse(uri);
|
||||||
} catch (IOException e1) {
|
} catch (IOException e1) {
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package org.parabot.core;
|
package org.parabot.core;
|
||||||
|
|
||||||
|
import org.parabot.environment.api.utils.Version;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds some important constants
|
* Holds some important constants
|
||||||
*
|
*
|
||||||
@@ -14,11 +16,12 @@ 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_BOT_VERSION = "http://bdn.parabot.org/api/v2/bot/version";
|
public static final String GET_BOT_VERSION = "http://bdn.parabot.org/api/v2/bot/version";
|
||||||
public static final String 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 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://bdn.parabot.org/api/get.php?action=randoms";
|
public static final String GET_RANDOMS = "http://bdn.parabot.org/api/get.php?action=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 BOT_VERSION = (String) ProjectProperties.getProjectVersion();
|
public static final Version BOT_VERSION = ProjectProperties.getProjectVersion();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import org.json.simple.JSONObject;
|
|||||||
import org.json.simple.parser.ParseException;
|
import org.json.simple.parser.ParseException;
|
||||||
import org.parabot.Landing;
|
import org.parabot.Landing;
|
||||||
import org.parabot.core.ui.utils.UILog;
|
import org.parabot.core.ui.utils.UILog;
|
||||||
|
import org.parabot.environment.api.utils.Version;
|
||||||
import org.parabot.environment.api.utils.WebUtil;
|
import org.parabot.environment.api.utils.WebUtil;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
@@ -21,6 +22,7 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
*
|
*
|
||||||
* @author Everel, JKetelaar
|
* @author Everel, JKetelaar
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("Duplicates")
|
||||||
public class Core {
|
public class Core {
|
||||||
public static boolean mDebug;
|
public static boolean mDebug;
|
||||||
private static boolean debug;
|
private static boolean debug;
|
||||||
@@ -31,6 +33,9 @@ public class Core {
|
|||||||
private static boolean validate = true;
|
private static boolean validate = true;
|
||||||
private static boolean secure = true;
|
private static boolean secure = true;
|
||||||
|
|
||||||
|
private static Version currentVersion = Configuration.BOT_VERSION;
|
||||||
|
private static Version latestVersion;
|
||||||
|
|
||||||
public static void disableValidation() {
|
public static void disableValidation() {
|
||||||
Core.validate = false;
|
Core.validate = false;
|
||||||
}
|
}
|
||||||
@@ -168,6 +173,8 @@ 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
|
* 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>.
|
||||||
*/
|
*/
|
||||||
@@ -201,6 +208,36 @@ public class Core {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean validVersion() {
|
||||||
|
BufferedReader br = WebUtil.getReader(Configuration.GET_BOT_VERSION);
|
||||||
|
try {
|
||||||
|
latestVersion = null;
|
||||||
|
if (br != null) {
|
||||||
|
JSONObject object = (JSONObject) WebUtil.getJsonParser().parse(br);
|
||||||
|
latestVersion = new Version((String) object.get("result"));
|
||||||
|
}
|
||||||
|
if (latestVersion != null) {
|
||||||
|
if (Configuration.BOT_VERSION.compareTo(latestVersion) < 0) {
|
||||||
|
Core.verbose("Our version: " + Configuration.BOT_VERSION.get());
|
||||||
|
Core.verbose("Latest version: " + latestVersion.get());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (NumberFormatException | IOException | ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if (br != null) {
|
||||||
|
br.close();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private static void validateCache(){
|
private static void validateCache(){
|
||||||
File[] cache = Directories.getCachePath().listFiles();
|
File[] cache = Directories.getCachePath().listFiles();
|
||||||
Integer lowest = null;
|
Integer lowest = null;
|
||||||
@@ -235,7 +272,7 @@ public class Core {
|
|||||||
Core.verbose("Checking for updates...");
|
Core.verbose("Checking for updates...");
|
||||||
validateCache();
|
validateCache();
|
||||||
|
|
||||||
if (versionValid() && checksumValid()){
|
if ((validVersion() && checksumValid()) || (!checksumValid() && currentVersion.compareTo(latestVersion) >= 0)){
|
||||||
Core.verbose("No updates available.");
|
Core.verbose("No updates available.");
|
||||||
return true;
|
return true;
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package org.parabot.core;
|
package org.parabot.core;
|
||||||
|
|
||||||
|
import org.parabot.environment.api.utils.Version;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
@@ -34,9 +36,8 @@ public class ProjectProperties {
|
|||||||
return cached;
|
return cached;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object getProjectVersion(){
|
public static Version getProjectVersion(){
|
||||||
System.out.println(getInstance().getCached().getProperty("application.version"));
|
return new Version(getInstance().getCached().getProperty("application.version"));
|
||||||
return getInstance().getCached().getProperty("application.version");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ProjectProperties getInstance(){
|
public static ProjectProperties getInstance(){
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package org.parabot.environment.api.utils;
|
||||||
|
|
||||||
|
public class Version implements Comparable<Version> {
|
||||||
|
|
||||||
|
private String version;
|
||||||
|
|
||||||
|
public final String get() {
|
||||||
|
return this.version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Version(String version) {
|
||||||
|
if(version == null) {
|
||||||
|
throw new IllegalArgumentException("Version can not be null");
|
||||||
|
}
|
||||||
|
if(!version.matches("[0-9]+(\\.[0-9]+)*")) {
|
||||||
|
throw new IllegalArgumentException("Invalid version format");
|
||||||
|
}
|
||||||
|
this.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public int compareTo(Version that) {
|
||||||
|
if(that == null) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
String[] thisParts = this.get().split("\\.");
|
||||||
|
String[] thatParts = that.get().split("\\.");
|
||||||
|
int length = Math.max(thisParts.length, thatParts.length);
|
||||||
|
for(int i = 0; i < length; i++) {
|
||||||
|
int thisPart = i < thisParts.length ?
|
||||||
|
Integer.parseInt(thisParts[i]) : 0;
|
||||||
|
int thatPart = i < thatParts.length ?
|
||||||
|
Integer.parseInt(thatParts[i]) : 0;
|
||||||
|
if(thisPart < thatPart) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if(thisPart > thatPart) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public boolean equals(Object that) {
|
||||||
|
return this == that || that != null && this.getClass() == that.getClass() && this.compareTo((Version) that) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user