From 65aec60ef5f86af4976c1abffd37fb0287b6e740 Mon Sep 17 00:00:00 2001 From: Gravit Date: Wed, 22 May 2019 05:39:12 +0700 Subject: [PATCH] =?UTF-8?q?[FEATURE]=20=D0=A1=D0=BE=D1=85=D1=80=D0=B0?= =?UTF-8?q?=D0=BD=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BA=D0=BB=D1=8E=D1=87=D0=B0?= =?UTF-8?q?=20=D1=80=D0=B0=D0=B7=D0=B1=D0=BB=D0=BE=D0=BA=D0=B8=D1=80=D0=BE?= =?UTF-8?q?=D0=B2=D0=BA=D0=B8=20=D0=BA=D0=BE=D0=BD=D1=81=D0=BE=D0=BB=D0=B8?= =?UTF-8?q?=20=D0=BC=D0=B5=D0=B6=D0=B4=D1=83=20=D0=B7=D0=B0=D0=BF=D1=83?= =?UTF-8?q?=D1=81=D0=BA=D0=B0=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/ru/gravit/launcher/NewLauncherSettings.java | 2 ++ .../java/ru/gravit/launcher/console/UnlockCommand.java | 3 +++ .../java/ru/gravit/launcher/managers/ConsoleManager.java | 2 ++ .../java/ru/gravit/launcher/managers/SettingsManager.java | 8 ++++++++ 4 files changed, 15 insertions(+) diff --git a/Launcher/src/main/java/ru/gravit/launcher/NewLauncherSettings.java b/Launcher/src/main/java/ru/gravit/launcher/NewLauncherSettings.java index 241b792f..25e3b1fe 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/NewLauncherSettings.java +++ b/Launcher/src/main/java/ru/gravit/launcher/NewLauncherSettings.java @@ -39,6 +39,8 @@ public class NewLauncherSettings { public Map userSettings = new HashMap<>(); @LauncherAPI public boolean featureStore; + @LauncherAPI + public String consoleUnlockKey; public static class HashedStoreEntry { @LauncherAPI diff --git a/Launcher/src/main/java/ru/gravit/launcher/console/UnlockCommand.java b/Launcher/src/main/java/ru/gravit/launcher/console/UnlockCommand.java index 0a9b5b73..a27a7ff3 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/console/UnlockCommand.java +++ b/Launcher/src/main/java/ru/gravit/launcher/console/UnlockCommand.java @@ -1,6 +1,7 @@ package ru.gravit.launcher.console; import ru.gravit.launcher.managers.ConsoleManager; +import ru.gravit.launcher.managers.SettingsManager; import ru.gravit.utils.command.Command; import ru.gravit.utils.helper.LogHelper; @@ -22,6 +23,8 @@ public void invoke(String... args) throws Exception { LogHelper.info("Unlock successful"); ConsoleManager.unlock(); ConsoleManager.handler.unregisterCommand("unlock"); + LogHelper.info("Write unlock key"); + SettingsManager.settings.consoleUnlockKey = args[0]; } else { LogHelper.error("Unlock key incorrect"); } diff --git a/Launcher/src/main/java/ru/gravit/launcher/managers/ConsoleManager.java b/Launcher/src/main/java/ru/gravit/launcher/managers/ConsoleManager.java index 209157f0..ac22db8d 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/managers/ConsoleManager.java +++ b/Launcher/src/main/java/ru/gravit/launcher/managers/ConsoleManager.java @@ -27,6 +27,7 @@ public class ConsoleManager { public static CommandHandler handler; public static Thread thread; + public static boolean isConsoleUnlock = false; public static void initConsole() throws IOException { CommandHandler localCommandHandler; @@ -69,5 +70,6 @@ public static void unlock() { store.registerCommand("copyStoreDir", new CopyStoreDirCommand()); store.registerCommand("linkStoreDir", new LinkStoreDirCommand()); handler.registerCategory(new CommandHandler.Category(admin, "store", "Store admin commands")); + isConsoleUnlock = true; } } diff --git a/Launcher/src/main/java/ru/gravit/launcher/managers/SettingsManager.java b/Launcher/src/main/java/ru/gravit/launcher/managers/SettingsManager.java index 693ad556..d6788e91 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/managers/SettingsManager.java +++ b/Launcher/src/main/java/ru/gravit/launcher/managers/SettingsManager.java @@ -61,6 +61,14 @@ public void setConfig(NewLauncherSettings config) { settings = config; if (settings.updatesDirPath != null) settings.updatesDir = Paths.get(settings.updatesDirPath); + if(settings.consoleUnlockKey != null && !ConsoleManager.isConsoleUnlock) + { + if(ConsoleManager.checkUnlockKey(settings.consoleUnlockKey)) + { + ConsoleManager.unlock(); + LogHelper.info("Console auto unlocked"); + } + } } @LauncherAPI