mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 05:06:45 +01:00
Make Updater work with our versioning setup.
This commit is contained in:
parent
4eba33a1c6
commit
3bc029a0de
@ -437,30 +437,49 @@ public class Updater
|
|||||||
if(type != UpdateType.NO_VERSION_CHECK)
|
if(type != UpdateType.NO_VERSION_CHECK)
|
||||||
{
|
{
|
||||||
String version = plugin.getDescription().getVersion();
|
String version = plugin.getDescription().getVersion();
|
||||||
|
title = title.substring(6);
|
||||||
|
|
||||||
String[] oldTokens = version.replaceAll("(?i)(-)(.+?)(-)", "-").split("[.]|-b");
|
String[] oldTokens = version.split("-");
|
||||||
String[] newTokens = title.replaceAll("(?i)(-)(.+?)(-)", "-").split("[.]|-b");
|
String[] newTokens = title.split("-");
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++) {
|
int oldVersion = Integer.parseInt(oldTokens[0].replaceAll(".", ""));
|
||||||
Integer newVer = Integer.parseInt(newTokens[i]);
|
int newVersion = Integer.parseInt(newTokens[0].replaceAll(".", ""));
|
||||||
Integer oldVer;
|
|
||||||
|
|
||||||
try {
|
// Check versions
|
||||||
oldVer = Integer.parseInt(oldTokens[i]);
|
if (oldVersion < newVersion) {
|
||||||
}
|
return true;
|
||||||
catch (NumberFormatException e) {
|
|
||||||
plugin.getLogger().warning("Could not get information about this mcMMO version; perhaps you are running a custom one?");
|
|
||||||
result = UpdateResult.FAIL_NOVERSION;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (oldVer < newVer) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result = Updater.UpdateResult.NO_UPDATE;
|
// Check release vs. beta & dev
|
||||||
return false;
|
if (newTokens.length == 0 && oldTokens.length == 2 && oldVersion == newVersion) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check beta vs. dev
|
||||||
|
if (version.contains("dev") && title.contains("beta")) {
|
||||||
|
if (Integer.parseInt(oldTokens[1].substring(3)) < Integer.parseInt(newTokens[1].substring(4))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = UpdateResult.NO_UPDATE;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check beta vs. beta
|
||||||
|
if (version.contains("beta") && title.contains("beta")) {
|
||||||
|
if (Integer.parseInt(oldTokens[1].substring(4)) < Integer.parseInt(newTokens[1].substring(4))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = UpdateResult.NO_UPDATE;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oldTokens.length == 2 && !version.contains("beta") && !version.contains("dev")) {
|
||||||
|
plugin.getLogger().warning("Could not get information about this mcMMO version; perhaps you are running a custom one?");
|
||||||
|
result = UpdateResult.FAIL_NOVERSION;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user