Update from Git Manager GUI
This commit is contained in:
Binary file not shown.
@@ -17,6 +17,29 @@ import java.util.function.Consumer;
|
|||||||
* new UpdateChecker(this, RESOURCE_ID).getVersion(version -> { ... });
|
* new UpdateChecker(this, RESOURCE_ID).getVersion(version -> { ... });
|
||||||
*/
|
*/
|
||||||
public class UpdateChecker {
|
public class UpdateChecker {
|
||||||
|
/**
|
||||||
|
* Vergleicht zwei Versionsnummern (z.B. "1.0.3" und "1.0.2").
|
||||||
|
* Gibt >0 zurück, wenn v1 > v2, <0 wenn v1 < v2, 0 wenn gleich.
|
||||||
|
*/
|
||||||
|
public static int compareVersions(String v1, String v2) {
|
||||||
|
String[] parts1 = v1.replace("v", "").split("\\.");
|
||||||
|
String[] parts2 = v2.replace("v", "").split("\\.");
|
||||||
|
int len = Math.max(parts1.length, parts2.length);
|
||||||
|
for (int i = 0; i < len; i++) {
|
||||||
|
int n1 = i < parts1.length ? parseIntSafe(parts1[i]) : 0;
|
||||||
|
int n2 = i < parts2.length ? parseIntSafe(parts2[i]) : 0;
|
||||||
|
if (n1 != n2) return Integer.compare(n1, n2);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int parseIntSafe(String s) {
|
||||||
|
try {
|
||||||
|
return Integer.parseInt(s.replaceAll("[^0-9]", ""));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private final JavaPlugin plugin;
|
private final JavaPlugin plugin;
|
||||||
private final int resourceId;
|
private final int resourceId;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
name: Fussball
|
name: Fussball
|
||||||
version: 1.0.4
|
version: 1.0.3
|
||||||
main: de.fussball.plugin.Fussball
|
main: de.fussball.plugin.Fussball
|
||||||
api-version: 1.21
|
api-version: 1.21
|
||||||
author: M_Viper
|
author: M_Viper
|
||||||
|
|||||||
Reference in New Issue
Block a user