Fix configuration formatting and loading issues

feat/data-edit-commands
William 3 years ago
parent 861a0b2824
commit eb0a8dbf47

@ -23,4 +23,4 @@ clusters:
player_table: 'husksync_players'
data_table: 'husksync_data'
check_for_updates: true
config_file_version: 1.1
config_file_version: 1.2

@ -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",

@ -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");

@ -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();
}

Loading…
Cancel
Save