From be4f80184cf5840cbde5f64add48188d2b3c1ca4 Mon Sep 17 00:00:00 2001 From: sandtechnology Date: Fri, 13 Aug 2021 18:37:05 +0800 Subject: [PATCH] Confirming update action before updating --- .../command/subcommand/SubCommand_Update.java | 10 +++++++--- 1 file changed, 7 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 f68895c96..9af54465c 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 @@ -46,12 +46,16 @@ public class SubCommand_Update implements CommandHandler { } if (plugin.getUpdateWatcher().getUpdater().isLatest(plugin.getUpdateWatcher().getUpdater().getCurrentRunning())) { - MsgUtil.sendDirectMessage(sender, ChatColor.GREEN + "You're running the latest version!."); + MsgUtil.sendDirectMessage(sender, ChatColor.GREEN + "You're running the latest version!"); return; } + if (cmdArg.length == 0 || !cmdArg[0].equalsIgnoreCase("confirm")) { + MsgUtil.sendDirectMessage(sender, ChatColor.RED + "You will need to restart the server to complete the update of plugin! Before restarting plugin will stop working!"); + MsgUtil.sendDirectMessage(sender, ChatColor.RED + "Type " + ChatColor.BOLD + "/qs update confirm" + ChatColor.RESET + ChatColor.RED + " to confirm update"); + return; + } 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())); } catch (Exception e) { @@ -64,7 +68,7 @@ public class SubCommand_Update implements CommandHandler { MsgUtil.sendDirectMessage(sender, ChatColor.GREEN + "Successful! Please restart your server to apply the updated version!"); MsgUtil.sendDirectMessage(sender, - ChatColor.YELLOW + "Before you restarting the server, QuickShop won't working again."); + ChatColor.RED + "Before you restarting the server, QuickShop won't working again."); plugin.setupBootError(new BootError(plugin.getLogger(), "Reboot required after update the plugin."), true); });