mirror of
https://github.com/PlaceholderAPI/PlaceholderAPI
synced 2024-11-22 02:06:48 +01:00
Fix version checker to compare the individual semver numbers instead of combining it together.
This commit is contained in:
parent
f5386d4ca5
commit
ef5cd9d376
@ -23,6 +23,7 @@ package me.clip.placeholderapi.updatechecker;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||
import me.clip.placeholderapi.util.Msg;
|
||||
@ -90,17 +91,22 @@ public class UpdateChecker implements Listener {
|
||||
return false;
|
||||
}
|
||||
|
||||
String plV = toReadable(pluginVersion);
|
||||
String spV = toReadable(spigotVersion);
|
||||
return plV.compareTo(spV) < 0;
|
||||
int[] plV = toReadable(pluginVersion);
|
||||
int[] spV = toReadable(spigotVersion);
|
||||
|
||||
if (plV[0] < spV[0]) {
|
||||
return true;
|
||||
} else if ((plV[1] < spV[1])) {
|
||||
return true;
|
||||
} else return plV[2] < spV[2];
|
||||
}
|
||||
|
||||
private String toReadable(String version) {
|
||||
if (version.contains("-DEV-")) {
|
||||
version = version.split("-DEV-")[0];
|
||||
private int[] toReadable(String version) {
|
||||
if (version.contains("-DEV")) {
|
||||
version = version.split("-DEV")[0];
|
||||
}
|
||||
|
||||
return version.replaceAll("\\.", "");
|
||||
return Arrays.stream(version.split("\\.")).mapToInt(Integer::parseInt).toArray();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
|
Loading…
Reference in New Issue
Block a user