private void initConfig() { if (Files.isRegularFile(Config.getConfigFile())) { try { config = Config.load(Config.getConfigFile()); } catch (IOException e) { logger.error("Failed to load config", e); config = new Config(); } } else { config = new Config(); } if (!config.getDefaultModSelection().hasModule(TerasologyConstants.CORE_GAMEPLAY_MODULE)) { config.getDefaultModSelection().addModule(TerasologyConstants.CORE_GAMEPLAY_MODULE); } if (!validateServerIdentity()) { CertificateGenerator generator = new CertificateGenerator(); CertificatePair serverIdentity = generator.generateSelfSigned(); config .getSecurity() .setServerCredentials(serverIdentity.getPublicCert(), serverIdentity.getPrivateCert()); config.save(); } renderingConfig = config.getRendering(); logger.info("Video Settings: " + renderingConfig.toString()); CoreRegistry.putPermanently(Config.class, config); }
private void cleanup() { logger.info("Shutting down Terasology..."); try { Iterator<EngineSubsystem> iter = subsystems.descendingIterator(); while (iter.hasNext()) { EngineSubsystem subsystem = iter.next(); subsystem.shutdown(config); } config.save(); if (currentState != null) { currentState.dispose(); currentState = null; } } finally { // Even if a graceful shutdown of the subsystems fails, // the thread pool has to be shut down stopThreads(); } }