From 0c86f02c498b731e83683c80f2dacce5f680482b Mon Sep 17 00:00:00 2001 From: Mark Vainomaa Date: Sun, 28 Oct 2018 18:15:32 +0200 Subject: [PATCH] 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. --- .../java/com/velocitypowered/proxy/VelocityServer.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java b/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java index 10c54c20..29d5dec2 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java @@ -147,16 +147,15 @@ public class VelocityServer implements ProxyServer { Path configPath = Paths.get("velocity.toml"); configuration = VelocityConfiguration.read(configPath); + AnnotatedConfig + .saveConfig(configuration.dumpConfig(), configPath); // Resave config to add new values + if (!configuration.validate()) { logger.error( "Your configuration is invalid. Velocity will refuse to start up until the errors are resolved."); LogManager.shutdown(); System.exit(1); } - - AnnotatedConfig - .saveConfig(configuration.dumpConfig(), configPath); //Resave config to add new values - } catch (Exception e) { logger.error("Unable to read/load/save your velocity.toml. The server will shut down.", e); LogManager.shutdown();