From eb0a8dbf47e06e80b86bdc211860edcd858d81ef Mon Sep 17 00:00:00 2001 From: William Date: Wed, 8 Dec 2021 15:02:43 +0000 Subject: [PATCH] Fix configuration formatting and loading issues --- common/src/main/resources/proxy-config.yml | 2 +- .../main/java/me/william278/husksync/HuskSyncVelocity.java | 2 +- .../william278/husksync/velocity/config/ConfigLoader.java | 5 +++-- .../william278/husksync/velocity/config/ConfigManager.java | 7 +++++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/common/src/main/resources/proxy-config.yml b/common/src/main/resources/proxy-config.yml index b54d463e..0da450ad 100644 --- a/common/src/main/resources/proxy-config.yml +++ b/common/src/main/resources/proxy-config.yml @@ -23,4 +23,4 @@ clusters: player_table: 'husksync_players' data_table: 'husksync_data' check_for_updates: true -config_file_version: 1.1 \ No newline at end of file +config_file_version: 1.2 \ No newline at end of file diff --git a/velocity/src/main/java/me/william278/husksync/HuskSyncVelocity.java b/velocity/src/main/java/me/william278/husksync/HuskSyncVelocity.java index 8ed9bfa7..4968f6d6 100644 --- a/velocity/src/main/java/me/william278/husksync/HuskSyncVelocity.java +++ b/velocity/src/main/java/me/william278/husksync/HuskSyncVelocity.java @@ -32,7 +32,7 @@ import java.util.logging.Level; import static me.william278.husksync.HuskSyncVelocity.VERSION; @Plugin( - id = "velocity", + id = "husksync", name = "HuskSync", version = VERSION, description = "HuskSync for velocity", diff --git a/velocity/src/main/java/me/william278/husksync/velocity/config/ConfigLoader.java b/velocity/src/main/java/me/william278/husksync/velocity/config/ConfigLoader.java index 4d9fee9b..0b57eaae 100644 --- a/velocity/src/main/java/me/william278/husksync/velocity/config/ConfigLoader.java +++ b/velocity/src/main/java/me/william278/husksync/velocity/config/ConfigLoader.java @@ -20,8 +20,8 @@ public class ConfigLoader { configRoot.getNode("check_for_updates").setValue(true); } if (configVersion.equalsIgnoreCase("1.0") || configVersion.equalsIgnoreCase("1.0.1") || configVersion.equalsIgnoreCase("1.0.2") || configVersion.equalsIgnoreCase("1.0.3")) { - configRoot.getNode("clusters.main.player_table").setValue("husksync_players"); - configRoot.getNode("clusters.main.data_table").setValue("husksync_data"); + configRoot.getNode("clusters", "main", "player_table").setValue("husksync_players"); + configRoot.getNode("clusters", "main", "data_table").setValue("husksync_data"); } configRoot.getNode("config_file_version").setValue(HuskSyncVelocity.VERSION); } @@ -49,6 +49,7 @@ public class ConfigLoader { public static void loadSettings(ConfigurationNode loadedConfig) throws IllegalArgumentException { ConfigurationNode config = copyDefaults(loadedConfig); + //ConfigurationNode config = copyDefaults(loadedConfig); Settings.language = getConfigString(config, "en-gb", "language"); diff --git a/velocity/src/main/java/me/william278/husksync/velocity/config/ConfigManager.java b/velocity/src/main/java/me/william278/husksync/velocity/config/ConfigManager.java index 05081861..a9024205 100644 --- a/velocity/src/main/java/me/william278/husksync/velocity/config/ConfigManager.java +++ b/velocity/src/main/java/me/william278/husksync/velocity/config/ConfigManager.java @@ -4,6 +4,7 @@ import me.william278.husksync.HuskSyncVelocity; import me.william278.husksync.Settings; import ninja.leaping.configurate.ConfigurationNode; import ninja.leaping.configurate.yaml.YAMLConfigurationLoader; +import org.yaml.snakeyaml.DumperOptions; import java.io.File; import java.io.IOException; @@ -24,7 +25,7 @@ public class ConfigManager { } File configFile = new File(plugin.getDataFolder(), "config.yml"); if (!configFile.exists()) { - Files.copy(Objects.requireNonNull(plugin.getClass().getResourceAsStream("proxy-config.yml")), configFile.toPath()); + Files.copy(Objects.requireNonNull(HuskSyncVelocity.class.getClassLoader().getResourceAsStream("proxy-config.yml")), configFile.toPath()); plugin.getVelocityLogger().info("Created HuskSync config file"); } } catch (Exception e) { @@ -49,7 +50,7 @@ public class ConfigManager { } File messagesFile = new File(plugin.getDataFolder(), "messages_" + Settings.language + ".yml"); if (!messagesFile.exists()) { - Files.copy(Objects.requireNonNull(plugin.getClass().getResourceAsStream("languages/" + Settings.language + ".yml")), + Files.copy(Objects.requireNonNull(HuskSyncVelocity.class.getClassLoader().getResourceAsStream("languages/" + Settings.language + ".yml")), messagesFile.toPath()); plugin.getVelocityLogger().info("Created HuskSync messages file"); } @@ -62,6 +63,8 @@ public class ConfigManager { File configFile = new File(plugin.getDataFolder(), "config.yml"); return YAMLConfigurationLoader.builder() .setPath(configFile.toPath()) + .setFlowStyle(DumperOptions.FlowStyle.BLOCK) + .setIndent(2) .build(); }