Fixed:
Version incorrectly reported in server log Added: Max length setting to config.yml
This commit is contained in:
1 parent
198c7c6aff
commit
4b7fb42dd3
3 files changed
+96
-13
No files matched your search
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
<groupId>com.rsscripting</groupId>
|
<groupId>com.rsscripting</groupId>
|
||||||
<artifactId>RS-Auger</artifactId>
|
<artifactId>RS-Auger</artifactId>
|
||||||
<version>1.0.0</version>
|
<version>1.0.1</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>21</maven.compiler.source>
|
<maven.compiler.source>21</maven.compiler.source>
|
||||||
@@ -39,4 +39,20 @@
|
|||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
|
||||||
|
<resources>
|
||||||
|
|
||||||
|
<resource>
|
||||||
|
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
|
||||||
|
<filtering>true</filtering>
|
||||||
|
|
||||||
|
</resource>
|
||||||
|
|
||||||
|
</resources>
|
||||||
|
|
||||||
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.rsscripting.rsauger.utils;
|
package com.rsscripting.rsauger.utils;
|
||||||
|
|
||||||
import com.rsscripting.rsauger.RSAuger;
|
import com.rsscripting.rsauger.RSAuger;
|
||||||
|
import com.rsscripting.rsauger.utils.RSConstants;
|
||||||
|
import com.rsscripting.rsauger.utils.VersionUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
@@ -38,11 +40,11 @@ public class GitHubUpdateChecker {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
String apiURL =
|
String apiURL =
|
||||||
"https://api.github.com/repos/"
|
"https://raw.githubusercontent.com/"
|
||||||
+ RSConstants.GITHUB_USER
|
+ RSConstants.GITHUB_USER
|
||||||
+ "/"
|
+ "/"
|
||||||
+ RSConstants.GITHUB_REPOSITORY
|
+ RSConstants.GITHUB_REPOSITORY
|
||||||
+ "/releases/latest";
|
+ "/master/pom.xml";
|
||||||
|
|
||||||
HttpURLConnection connection =
|
HttpURLConnection connection =
|
||||||
(HttpURLConnection)
|
(HttpURLConnection)
|
||||||
@@ -72,12 +74,13 @@ public class GitHubUpdateChecker {
|
|||||||
|
|
||||||
reader.close();
|
reader.close();
|
||||||
|
|
||||||
String json =
|
String pom =
|
||||||
response.toString();
|
response.toString();
|
||||||
|
|
||||||
latestVersion =
|
latestVersion =
|
||||||
json.split("\"tag_name\":\"")[1]
|
pom.split("<version>")[1]
|
||||||
.split("\"")[0];
|
.split("</version>")[0]
|
||||||
|
.trim();
|
||||||
|
|
||||||
String currentVersion =
|
String currentVersion =
|
||||||
VersionUtils.getVersion();
|
VersionUtils.getVersion();
|
||||||
@@ -88,9 +91,18 @@ public class GitHubUpdateChecker {
|
|||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!latestVersion.equalsIgnoreCase(
|
if (latestVersion == null) {
|
||||||
currentVersion
|
|
||||||
)) {
|
updateStatus =
|
||||||
|
"Unable To Check";
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (
|
||||||
|
compareVersions(
|
||||||
|
latestVersion,
|
||||||
|
currentVersion
|
||||||
|
) > 0
|
||||||
|
) {
|
||||||
|
|
||||||
updateStatus =
|
updateStatus =
|
||||||
"Update Available";
|
"Update Available";
|
||||||
@@ -122,7 +134,7 @@ public class GitHubUpdateChecker {
|
|||||||
Bukkit.getConsoleSender().sendMessage(
|
Bukkit.getConsoleSender().sendMessage(
|
||||||
|
|
||||||
RSConstants.PREFIX
|
RSConstants.PREFIX
|
||||||
+ "Plugin is up to date."
|
+ "RS-Auger is up to date."
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -132,13 +144,15 @@ public class GitHubUpdateChecker {
|
|||||||
|
|
||||||
catch (Exception exception) {
|
catch (Exception exception) {
|
||||||
|
|
||||||
|
latestVersion = null;
|
||||||
|
|
||||||
updateStatus =
|
updateStatus =
|
||||||
"Unable To Check";
|
"Unable To Check";
|
||||||
|
|
||||||
Bukkit.getConsoleSender().sendMessage(
|
Bukkit.getConsoleSender().sendMessage(
|
||||||
|
|
||||||
RSConstants.PREFIX
|
RSConstants.PREFIX
|
||||||
+ "Failed to check for updates."
|
+ "Unable to check for updates."
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -174,4 +188,57 @@ public class GitHubUpdateChecker {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
name: RS-Auger
|
name: RS-Auger
|
||||||
version: 1.0.0
|
version: ${project.version}
|
||||||
main: com.rsscripting.rsauger.RSAuger
|
main: com.rsscripting.rsauger.RSAuger
|
||||||
api-version: '1.21'
|
api-version: '1.21'
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user