Always update if you can

This commit is contained in:
libraryaddict 2020-09-19 07:24:12 +12:00
parent ac574bc51c
commit a66b41e4f5

View File

@ -40,8 +40,6 @@ public class LDUpdate implements LDCommand {
} }
boolean releaseBuilds = checker.isUsingReleaseBuilds(); boolean releaseBuilds = checker.isUsingReleaseBuilds();
boolean wantsCheck = args[0].endsWith("?");
boolean wantsDownload = args[0].endsWith("!") || !wantsCheck;
if (args.length > 1) { if (args.length > 1) {
boolean previous = releaseBuilds; boolean previous = releaseBuilds;
@ -55,45 +53,20 @@ public class LDUpdate implements LDCommand {
return; return;
} }
if (previous != releaseBuilds && !wantsCheck) {
wantsDownload = true;
}
wantsCheck = true;
DisguiseConfig.setUsingReleaseBuilds(releaseBuilds); DisguiseConfig.setUsingReleaseBuilds(releaseBuilds);
} }
if (checker.getUpdate() != null && checker.getUpdate().isReleaseBuild() == releaseBuilds && !wantsCheck) {
if (checker.isServerLatestVersion()) {
LibsMsg.UPDATE_ON_LATEST.send(sender);
return;
}
if (checker.isOnLatestUpdate(true)) {
LibsMsg.UPDATE_ALREADY_DOWNLOADED.send(sender);
return;
}
}
boolean finalWantsCheck = wantsCheck;
boolean finalWantsDownload = wantsDownload;
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
LibsMsg updateResult = null; LibsMsg updateResult = checker.doUpdateCheck();
if (checker.getUpdate() == null || args.length > 1 || checker.isOldUpdate() || finalWantsCheck) {
updateResult = checker.doUpdateCheck();
}
if (checker.getUpdate() == null) { if (checker.getUpdate() == null) {
LibsMsg.UPDATE_FAILED.send(sender); LibsMsg.UPDATE_FAILED.send(sender);
return; return;
} }
if (checker.isOnLatestUpdate(true) && !finalWantsDownload) { if (checker.isOnLatestUpdate(true)) {
if (checker.getLastDownload() != null) { if (checker.getLastDownload() != null) {
LibsMsg.UPDATE_ALREADY_DOWNLOADED.send(sender); LibsMsg.UPDATE_ALREADY_DOWNLOADED.send(sender);
} else { } else {
@ -103,7 +76,7 @@ public class LDUpdate implements LDCommand {
return; return;
} }
if (!finalWantsDownload) { /*if (!finalWantsDownload) {
if (updateResult != null) { if (updateResult != null) {
updateResult.send(sender); updateResult.send(sender);
} else { } else {
@ -113,7 +86,7 @@ public class LDUpdate implements LDCommand {
} }
return; return;
} }*/
PluginInformation result = checker.doUpdate(); PluginInformation result = checker.doUpdate();