Перевод конфигов на Json часть 5

Правки рантайма
Комплируется, пока не работает
This commit is contained in:
Gravit 2018-12-23 23:47:07 +07:00
parent 123250246c
commit 2c06cdec24
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
2 changed files with 13 additions and 16 deletions

View file

@ -1,6 +1,7 @@
package ru.gravit.launchserver;
import com.google.gson.GsonBuilder;
import com.google.gson.annotations.Expose;
import ru.gravit.launcher.Launcher;
import ru.gravit.launcher.LauncherConfig;
import ru.gravit.launcher.hasher.HashedDir;
@ -89,7 +90,9 @@ public static final class Config {
public String[] mirrors;
public String binaryName;
@Expose
private String address;
@Expose
private String bindAddress;
public LauncherConfig.LauncherEnvironment env;
public boolean isWarningMissArchJava;
@ -301,6 +304,7 @@ public LaunchServer(Path dir) throws IOException, InvalidKeySpecException {
modulesManager.autoload(dir.resolve("modules"));
modulesManager.preInitModules();
initGson();
LogHelper.setStacktraceEnabled(true);
// Read LaunchServer config
generateConfigIfNotExists();
@ -356,6 +360,7 @@ public static void initGson()
{
if(Launcher.gson != null) return;
Launcher.gsonBuilder = new GsonBuilder();
Launcher.gsonBuilder.setPrettyPrinting();
Launcher.gson = Launcher.gsonBuilder.create();
}
@ -402,10 +407,14 @@ private void generateConfigIfNotExists() throws IOException {
// Create new config
LogHelper.info("Creating LaunchServer config");
Config newConfig;
try (BufferedReader reader = IOHelper.newReader(IOHelper.getResourceURL("ru/gravit/launchserver/defaults/config.cfg"))) {
newConfig = Launcher.gson.fromJson(reader,Config.class);
}
Config newConfig = new Config();
newConfig.mirrors = new String[]{"http://mirror.gravitlauncher.ml"};
newConfig.launch4j = new ExeConf();
newConfig.buildPostTransform = new PostBuildTransformConf();
newConfig.env = LauncherConfig.LauncherEnvironment.STD;
//try (BufferedReader reader = IOHelper.newReader(IOHelper.getResourceURL("ru/gravit/launchserver/defaults/config.cfg"))) {
// newConfig = Launcher.gson.fromJson(reader,Config.class);
//}
// Set server address
LogHelper.println("LaunchServer address: ");

View file

@ -45,18 +45,6 @@ var SignedBytesHolder = SignedBytesHolderClass.static;
var SignedObjectHolder = SignedObjectHolderClass.static;
var EnumSerializer = EnumSerializerClass.static;
// Config serialization class bindings
var ConfigObject = ConfigObjectClass.static;
var ConfigObjectAdapter = ConfigObjectAdapterClass.static;
var BlockConfigEntry = BlockConfigEntryClass.static;
var BooleanConfigEntry = BooleanConfigEntryClass.static;
var IntegerConfigEntry = IntegerConfigEntryClass.static;
var ListConfigEntry = ListConfigEntryClass.static;
var StringConfigEntry = StringConfigEntryClass.static;
var ConfigEntryType = ConfigEntryTypeClass.static;
var TextConfigReader = TextConfigReaderClass.static;
var TextConfigWriter = TextConfigWriterClass.static;
// Helper class API imports
var CommonHelper = CommonHelperClass.static;
var IOHelper = IOHelperClass.static;