[FEATURE] Сохранение ключа разблокировки консоли между запусками

This commit is contained in:
Gravit 2019-05-22 05:39:12 +07:00
parent c5635de295
commit 65aec60ef5
4 changed files with 15 additions and 0 deletions

View file

@ -39,6 +39,8 @@ public class NewLauncherSettings {
public Map<String, UserSettings> userSettings = new HashMap<>(); public Map<String, UserSettings> userSettings = new HashMap<>();
@LauncherAPI @LauncherAPI
public boolean featureStore; public boolean featureStore;
@LauncherAPI
public String consoleUnlockKey;
public static class HashedStoreEntry { public static class HashedStoreEntry {
@LauncherAPI @LauncherAPI

View file

@ -1,6 +1,7 @@
package ru.gravit.launcher.console; package ru.gravit.launcher.console;
import ru.gravit.launcher.managers.ConsoleManager; import ru.gravit.launcher.managers.ConsoleManager;
import ru.gravit.launcher.managers.SettingsManager;
import ru.gravit.utils.command.Command; import ru.gravit.utils.command.Command;
import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.LogHelper;
@ -22,6 +23,8 @@ public void invoke(String... args) throws Exception {
LogHelper.info("Unlock successful"); LogHelper.info("Unlock successful");
ConsoleManager.unlock(); ConsoleManager.unlock();
ConsoleManager.handler.unregisterCommand("unlock"); ConsoleManager.handler.unregisterCommand("unlock");
LogHelper.info("Write unlock key");
SettingsManager.settings.consoleUnlockKey = args[0];
} else { } else {
LogHelper.error("Unlock key incorrect"); LogHelper.error("Unlock key incorrect");
} }

View file

@ -27,6 +27,7 @@
public class ConsoleManager { public class ConsoleManager {
public static CommandHandler handler; public static CommandHandler handler;
public static Thread thread; public static Thread thread;
public static boolean isConsoleUnlock = false;
public static void initConsole() throws IOException { public static void initConsole() throws IOException {
CommandHandler localCommandHandler; CommandHandler localCommandHandler;
@ -69,5 +70,6 @@ public static void unlock() {
store.registerCommand("copyStoreDir", new CopyStoreDirCommand()); store.registerCommand("copyStoreDir", new CopyStoreDirCommand());
store.registerCommand("linkStoreDir", new LinkStoreDirCommand()); store.registerCommand("linkStoreDir", new LinkStoreDirCommand());
handler.registerCategory(new CommandHandler.Category(admin, "store", "Store admin commands")); handler.registerCategory(new CommandHandler.Category(admin, "store", "Store admin commands"));
isConsoleUnlock = true;
} }
} }

View file

@ -61,6 +61,14 @@ public void setConfig(NewLauncherSettings config) {
settings = config; settings = config;
if (settings.updatesDirPath != null) if (settings.updatesDirPath != null)
settings.updatesDir = Paths.get(settings.updatesDirPath); 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 @LauncherAPI