use of de.dytanic.cloudnet.web.server.util.WebServerConfig in project CloudNet by Dytanic.
the class CloudConfig method load.
public CloudConfig load() throws Exception {
try (InputStream inputStream = Files.newInputStream(configPath);
InputStreamReader inputStreamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8)) {
Configuration configuration = CONFIGURATION_PROVIDER.load(inputStreamReader);
this.config = configuration;
String host = configuration.getString("server.hostaddress");
Collection<ConnectableAddress> addresses = new ArrayList<>();
for (int value : configuration.getIntList("server.ports")) {
addresses.add(new ConnectableAddress(host, value));
}
this.addresses = addresses;
this.wrapperKey = NetworkUtils.readWrapperKey();
this.autoUpdate = configuration.getBoolean("general.auto-update");
this.notifyService = configuration.getBoolean("general.notify-service");
this.cloudDevServices = configuration.getBoolean("general.devservices");
this.cloudDynamicServices = configuration.getBoolean("general.dynamicservices");
this.webServerConfig = new WebServerConfig(true, configuration.getString("server.webservice.hostaddress"), configuration.getInt("server.webservice.port"));
this.formatSplitter = configuration.getString("general.server-name-splitter");
this.networkProperties = configuration.getSection("networkproperties").self;
// configuration.set("general.disabled-modules", new ArrayList<>());
if (!configuration.getSection("general").self.containsKey("disabled-modules")) {
configuration.set("general.disabled-modules", new ArrayList<>());
try (OutputStreamWriter outputStreamWriter = new OutputStreamWriter(Files.newOutputStream(configPath), StandardCharsets.UTF_8)) {
CONFIGURATION_PROVIDER.save(configuration, outputStreamWriter);
}
}
if (!configuration.getSection("general").self.containsKey("cloudGameServer-wrapperList")) {
configuration.set("general.cloudGameServer-wrapperList", Arrays.asList("Wrapper-1"));
try (OutputStreamWriter outputStreamWriter = new OutputStreamWriter(Files.newOutputStream(configPath), StandardCharsets.UTF_8)) {
CONFIGURATION_PROVIDER.save(configuration, outputStreamWriter);
}
}
this.disabledModules = configuration.getStringList("general.disabled-modules");
this.cloudServerWrapperList = configuration.getStringList("general.cloudGameServer-wrapperList");
}
this.serviceDocument = Document.loadDocument(servicePath);
this.wrappers = this.serviceDocument.getObject("wrapper", new TypeToken<List<WrapperMeta>>() {
}.getType());
this.userDocument = Document.loadDocument(usersPath);
/* ============================================================== */
return this;
}
Aggregations