From fc550fbfea2fae35b7934d02565c6d1e45b2567a Mon Sep 17 00:00:00 2001 From: sandtechnology Date: Fri, 13 Aug 2021 18:48:27 +0800 Subject: [PATCH] Optimize the code of update command --- .../quickshop/command/subcommand/SubCommand_Update.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/maxgamer/quickshop/command/subcommand/SubCommand_Update.java b/src/main/java/org/maxgamer/quickshop/command/subcommand/SubCommand_Update.java index 9af54465c..6ff10ea06 100644 --- a/src/main/java/org/maxgamer/quickshop/command/subcommand/SubCommand_Update.java +++ b/src/main/java/org/maxgamer/quickshop/command/subcommand/SubCommand_Update.java @@ -27,6 +27,8 @@ import org.maxgamer.quickshop.BootError; import org.maxgamer.quickshop.QuickShop; import org.maxgamer.quickshop.command.CommandHandler; import org.maxgamer.quickshop.util.MsgUtil; +import org.maxgamer.quickshop.util.updater.QuickUpdater; +import org.maxgamer.quickshop.util.updater.VersionType; import java.util.logging.Level; @@ -44,8 +46,9 @@ public class SubCommand_Update implements CommandHandler { MsgUtil.sendDirectMessage(sender, ChatColor.RED + "It seems like the Updater has been disabled."); return; } - - if (plugin.getUpdateWatcher().getUpdater().isLatest(plugin.getUpdateWatcher().getUpdater().getCurrentRunning())) { + QuickUpdater updater = plugin.getUpdateWatcher().getUpdater(); + VersionType versionType = updater.getCurrentRunning(); + if (updater.isLatest(versionType)) { MsgUtil.sendDirectMessage(sender, ChatColor.GREEN + "You're running the latest version!"); return; } @@ -57,7 +60,7 @@ public class SubCommand_Update implements CommandHandler { } MsgUtil.sendDirectMessage(sender, ChatColor.YELLOW + "Downloading update! This may take a while..."); try { - plugin.getUpdateWatcher().getUpdater().install(plugin.getUpdateWatcher().getUpdater().update(plugin.getUpdateWatcher().getUpdater().getCurrentRunning())); + updater.install(updater.update(versionType)); } catch (Exception e) { MsgUtil.sendDirectMessage(sender, ChatColor.RED + "Update failed! Please check your console for more information."); plugin.getSentryErrorReporter().ignoreThrow();