diff --git a/pom.xml b/pom.xml
index 0c1e1c4..69b7a95 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,7 @@
com.rsscripting
RS-Auger
- 1.0.0
+ 1.0.1
21
@@ -39,4 +39,20 @@
+
+
+
+
+
+
+ src/main/resources
+
+ true
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/com/rsscripting/rsauger/utils/GitHubUpdateChecker.java b/src/main/java/com/rsscripting/rsauger/utils/GitHubUpdateChecker.java
index f315bfc..de0cdb2 100644
--- a/src/main/java/com/rsscripting/rsauger/utils/GitHubUpdateChecker.java
+++ b/src/main/java/com/rsscripting/rsauger/utils/GitHubUpdateChecker.java
@@ -1,6 +1,8 @@
package com.rsscripting.rsauger.utils;
import com.rsscripting.rsauger.RSAuger;
+import com.rsscripting.rsauger.utils.RSConstants;
+import com.rsscripting.rsauger.utils.VersionUtils;
import org.bukkit.Bukkit;
import java.io.BufferedReader;
@@ -38,11 +40,11 @@ public class GitHubUpdateChecker {
try {
String apiURL =
- "https://api.github.com/repos/"
+ "https://raw.githubusercontent.com/"
+ RSConstants.GITHUB_USER
+ "/"
+ RSConstants.GITHUB_REPOSITORY
- + "/releases/latest";
+ + "/master/pom.xml";
HttpURLConnection connection =
(HttpURLConnection)
@@ -72,12 +74,13 @@ public class GitHubUpdateChecker {
reader.close();
- String json =
+ String pom =
response.toString();
latestVersion =
- json.split("\"tag_name\":\"")[1]
- .split("\"")[0];
+ pom.split("")[1]
+ .split("")[0]
+ .trim();
String currentVersion =
VersionUtils.getVersion();
@@ -88,9 +91,18 @@ public class GitHubUpdateChecker {
|--------------------------------------------------------------------------
*/
- if (!latestVersion.equalsIgnoreCase(
- currentVersion
- )) {
+ if (latestVersion == null) {
+
+ updateStatus =
+ "Unable To Check";
+
+ }
+ else if (
+ compareVersions(
+ latestVersion,
+ currentVersion
+ ) > 0
+ ) {
updateStatus =
"Update Available";
@@ -122,7 +134,7 @@ public class GitHubUpdateChecker {
Bukkit.getConsoleSender().sendMessage(
RSConstants.PREFIX
- + "Plugin is up to date."
+ + "RS-Auger is up to date."
);
@@ -132,13 +144,15 @@ public class GitHubUpdateChecker {
catch (Exception exception) {
+ latestVersion = null;
+
updateStatus =
"Unable To Check";
Bukkit.getConsoleSender().sendMessage(
RSConstants.PREFIX
- + "Failed to check for updates."
+ + "Unable to check for updates."
);
@@ -174,4 +188,57 @@ public class GitHubUpdateChecker {
}
-}
\ No newline at end of file
+ /*
+ |--------------------------------------------------------------------------
+ | VERSION COMPARISON
+ |--------------------------------------------------------------------------
+ */
+
+ private static int compareVersions(
+ String version1,
+ String version2
+ ) {
+
+ String[] v1 =
+ version1.split("\\.");
+
+ String[] v2 =
+ version2.split("\\.");
+
+ int length =
+ Math.max(
+ v1.length,
+ v2.length
+ );
+
+ for (int i = 0; i < length; i++) {
+
+ int num1 =
+ i < v1.length
+ ? Integer.parseInt(v1[i])
+ : 0;
+
+ int num2 =
+ i < v2.length
+ ? Integer.parseInt(v2[i])
+ : 0;
+
+ if (num1 < num2) {
+
+ return -1;
+
+ }
+
+ if (num1 > num2) {
+
+ return 1;
+
+ }
+
+ }
+
+ return 0;
+
+ }
+
+}
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 43aceb5..eaa58bd 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,5 +1,5 @@
name: RS-Auger
-version: 1.0.0
+version: ${project.version}
main: com.rsscripting.rsauger.RSAuger
api-version: '1.21'