mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
[FEATURE] Сохранение ключа разблокировки консоли между запусками
This commit is contained in:
parent
c5635de295
commit
65aec60ef5
4 changed files with 15 additions and 0 deletions
|
@ -39,6 +39,8 @@ public class NewLauncherSettings {
|
|||
public Map<String, UserSettings> userSettings = new HashMap<>();
|
||||
@LauncherAPI
|
||||
public boolean featureStore;
|
||||
@LauncherAPI
|
||||
public String consoleUnlockKey;
|
||||
|
||||
public static class HashedStoreEntry {
|
||||
@LauncherAPI
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue