[FEATURE] Удалено большинство настроек, относвщихся к рантайму

This commit is contained in:
Gravit 2019-12-05 01:22:07 +07:00
parent f839691c87
commit 4136f4a6e8
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
8 changed files with 52 additions and 250 deletions

View file

@ -8,37 +8,10 @@
import java.util.*;
public class NewLauncherSettings {
@LauncherAPI
public String login;
@LauncherAPI
public String auth;
@LauncherAPI
public byte[] rsaPassword;
@LauncherAPI
public int profile;
@LauncherAPI
public transient Path updatesDir;
@LauncherAPI
public String updatesDirPath;
@LauncherAPI
public boolean autoEnter;
@LauncherAPI
public boolean debug;
@LauncherAPI
public boolean fullScreen;
@LauncherAPI
public boolean offline;
@LauncherAPI
public int ram;
@LauncherAPI
public byte[] lastDigest;
@LauncherAPI
public List<ClientProfile> lastProfiles = new LinkedList<>();
@LauncherAPI
public Map<String, UserSettings> userSettings = new HashMap<>();
@LauncherAPI
public boolean featureStore;
public List<String> features = new ArrayList<>();
@LauncherAPI
public String consoleUnlockKey;

View file

@ -22,7 +22,6 @@ public class LauncherUpdateController {
public void postDiff(UpdateRequest request, UpdateRequestEvent e, HashedDir.Diff diff) throws IOException {
if (e.zip && e.fullDownload) return;
if (SettingsManager.settings.featureStore) {
LogHelper.info("Enabled HStore feature. Find");
AtomicReference<NewLauncherSettings.HashedStoreEntry> lastEn = new AtomicReference<>(null);
//ArrayList<String> removed = new ArrayList<>();
@ -76,7 +75,6 @@ public void postDiff(UpdateRequest request, UpdateRequestEvent e, HashedDir.Diff
return HashedDir.WalkAction.CONTINUE;
});
}
}
public Path tryFind(NewLauncherSettings.HashedStoreEntry en, HashedFile file) throws IOException {
AtomicReference<Path> ret = new AtomicReference<>(null);

View file

@ -1,34 +0,0 @@
package pro.gravit.launcher.console;
import pro.gravit.launcher.managers.SettingsManager;
import pro.gravit.utils.command.Command;
import pro.gravit.utils.helper.LogHelper;
public class FeatureCommand extends Command {
@Override
public String getArgsDescription() {
return "[feature] [true/false]";
}
@Override
public String getUsageDescription() {
return "Enable or disable feature";
}
@Override
public void invoke(String... args) throws Exception {
verifyArgs(args, 2);
boolean enabled = Boolean.parseBoolean(args[1]);
switch (args[0]) {
case "store": {
SettingsManager.settings.featureStore = enabled;
break;
}
default: {
LogHelper.info("Features: [store]");
return;
}
}
LogHelper.info("Feature %s %s", args[0], enabled ? "enabled" : "disabled");
}
}

View file

@ -1,47 +0,0 @@
package pro.gravit.launcher.console.store;
import pro.gravit.launcher.NewLauncherSettings;
import pro.gravit.launcher.managers.SettingsManager;
import pro.gravit.utils.command.Command;
import pro.gravit.utils.helper.LogHelper;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
public class CopyStoreDirCommand extends Command {
@Override
public String getArgsDescription() {
return "[index] [overwrite(true/false)]";
}
@Override
public String getUsageDescription() {
return "Copy dir in GravitLauncherStore";
}
@Override
public void invoke(String... args) throws Exception {
verifyArgs(args, 2);
int ind = 1;
int index = Integer.parseInt(args[0]);
boolean overwrite = Boolean.parseBoolean(args[1]);
for (NewLauncherSettings.HashedStoreEntry e : SettingsManager.settings.lastHDirs) {
if (ind == index) {
LogHelper.info("Copy [%d] FullPath: %s name: %s", ind, e.fullPath, e.name);
Path path = Paths.get(e.fullPath);
if (!Files.isDirectory(path)) {
LogHelper.error("Directory %s not found", path.toAbsolutePath().toString());
return;
}
Path target = Paths.get(SettingsManager.settings.updatesDirPath).resolve(e.name);
if (Files.exists(target) && !overwrite) {
LogHelper.error("Directory %s found, flag overwrite not found", target.toAbsolutePath().toString());
return;
}
Files.copy(path, target);
}
ind++;
}
}
}

View file

@ -1,47 +0,0 @@
package pro.gravit.launcher.console.store;
import pro.gravit.launcher.NewLauncherSettings;
import pro.gravit.launcher.managers.SettingsManager;
import pro.gravit.utils.command.Command;
import pro.gravit.utils.helper.LogHelper;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
public class LinkStoreDirCommand extends Command {
@Override
public String getArgsDescription() {
return "[index]";
}
@Override
public String getUsageDescription() {
return "Create symlink to GravitLauncherStore directory";
}
@Override
public void invoke(String... args) throws Exception {
verifyArgs(args, 1);
int ind = 1;
int index = Integer.parseInt(args[0]);
for (NewLauncherSettings.HashedStoreEntry e : SettingsManager.settings.lastHDirs) {
if (ind == index) {
LogHelper.info("Copy [%d] FullPath: %s name: %s", ind, e.fullPath, e.name);
Path path = Paths.get(e.fullPath);
if (!Files.isDirectory(path)) {
LogHelper.error("Directory %s not found", path.toAbsolutePath().toString());
return;
}
Path target = Paths.get(SettingsManager.settings.updatesDirPath).resolve(e.name);
if (Files.exists(target)) {
LogHelper.error("Directory %s already exists", target.toAbsolutePath().toString());
return;
}
Files.createSymbolicLink(path, target);
}
ind++;
}
}
}

View file

@ -1,27 +0,0 @@
package pro.gravit.launcher.console.store;
import pro.gravit.launcher.NewLauncherSettings;
import pro.gravit.launcher.managers.SettingsManager;
import pro.gravit.utils.command.Command;
import pro.gravit.utils.helper.LogHelper;
public class StoreListCommand extends Command {
@Override
public String getArgsDescription() {
return null;
}
@Override
public String getUsageDescription() {
return "List GravitLauncherStore";
}
@Override
public void invoke(String... args) {
int ind = 1;
for (NewLauncherSettings.HashedStoreEntry e : SettingsManager.settings.lastHDirs) {
LogHelper.info("[%d] FullPath: %s name: %s", ind, e.fullPath, e.name);
ind++;
}
}
}

View file

@ -1,13 +1,9 @@
package pro.gravit.launcher.managers;
import pro.gravit.launcher.Launcher;
import pro.gravit.launcher.console.FeatureCommand;
import pro.gravit.launcher.console.UnlockCommand;
import pro.gravit.launcher.console.admin.ExecCommand;
import pro.gravit.launcher.console.admin.LogListenerCommand;
import pro.gravit.launcher.console.store.CopyStoreDirCommand;
import pro.gravit.launcher.console.store.LinkStoreDirCommand;
import pro.gravit.launcher.console.store.StoreListCommand;
import pro.gravit.utils.command.BaseCommandCategory;
import pro.gravit.utils.command.CommandHandler;
import pro.gravit.utils.command.JLineCommandHandler;
@ -57,16 +53,10 @@ public static boolean checkUnlockKey(String key) {
public static void unlock() {
handler.registerCommand("debug", new DebugCommand());
handler.registerCommand("feature", new FeatureCommand());
BaseCommandCategory admin = new BaseCommandCategory();
admin.registerCommand("exec", new ExecCommand());
admin.registerCommand("logListen", new LogListenerCommand());
handler.registerCategory(new CommandHandler.Category(admin, "admin", "Server admin commands"));
BaseCommandCategory store = new BaseCommandCategory();
store.registerCommand("storeList", new StoreListCommand());
store.registerCommand("copyStoreDir", new CopyStoreDirCommand());
store.registerCommand("linkStoreDir", new LinkStoreDirCommand());
handler.registerCategory(new CommandHandler.Category(admin, "store", "Store admin commands"));
isConsoleUnlock = true;
}
}

View file

@ -42,8 +42,6 @@ public SettingsManager() {
@LauncherAPI
@Override
public NewLauncherSettings getConfig() {
if (settings.updatesDir != null)
settings.updatesDirPath = settings.updatesDir.toString();
return settings;
}
@ -57,8 +55,6 @@ public NewLauncherSettings getDefaultConfig() {
@Override
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();