3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-17 05:20:14 +01:00

Save configuration after loading to ensure new options being present in file

For example if you had `[forced-hosts]` section missing, and `[servers]`
section not having entries similar to default forced hosts ones, then
new configuration would fail at validation and new options wouldn't be
saved to file at all.
Dieser Commit ist enthalten in:
Mark Vainomaa 2018-10-28 18:15:32 +02:00
Ursprung 070631902a
Commit 0c86f02c49
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 1B3F9523B542D315

Datei anzeigen

@ -147,16 +147,15 @@ public class VelocityServer implements ProxyServer {
Path configPath = Paths.get("velocity.toml"); Path configPath = Paths.get("velocity.toml");
configuration = VelocityConfiguration.read(configPath); configuration = VelocityConfiguration.read(configPath);
AnnotatedConfig
.saveConfig(configuration.dumpConfig(), configPath); // Resave config to add new values
if (!configuration.validate()) { if (!configuration.validate()) {
logger.error( logger.error(
"Your configuration is invalid. Velocity will refuse to start up until the errors are resolved."); "Your configuration is invalid. Velocity will refuse to start up until the errors are resolved.");
LogManager.shutdown(); LogManager.shutdown();
System.exit(1); System.exit(1);
} }
AnnotatedConfig
.saveConfig(configuration.dumpConfig(), configPath); //Resave config to add new values
} catch (Exception e) { } catch (Exception e) {
logger.error("Unable to read/load/save your velocity.toml. The server will shut down.", e); logger.error("Unable to read/load/save your velocity.toml. The server will shut down.", e);
LogManager.shutdown(); LogManager.shutdown();