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