diff --git a/src/main/java/com/drtshock/playervaults/PlayerVaults.java b/src/main/java/com/drtshock/playervaults/PlayerVaults.java index ebeb9c6..1081367 100644 --- a/src/main/java/com/drtshock/playervaults/PlayerVaults.java +++ b/src/main/java/com/drtshock/playervaults/PlayerVaults.java @@ -311,7 +311,7 @@ public class PlayerVaults extends JavaPlugin { private void loadConfig() { File configYaml = new File(this.getDataFolder(), "config.yml"); - if (configYaml.exists()) { + if (!(new File(this.getDataFolder(), "config.conf").exists()) && configYaml.exists()) { this.config.setFromConfig(this.getLogger(), this.getConfig()); try { Files.move(configYaml.toPath(), this.getDataFolder().toPath().resolve("old_unused_config.yml")); diff --git a/src/main/java/com/drtshock/playervaults/config/Loader.java b/src/main/java/com/drtshock/playervaults/config/Loader.java index ac854aa..fa71b45 100644 --- a/src/main/java/com/drtshock/playervaults/config/Loader.java +++ b/src/main/java/com/drtshock/playervaults/config/Loader.java @@ -18,6 +18,8 @@ package com.drtshock.playervaults.config; import com.drtshock.playervaults.PlayerVaults; +import com.drtshock.playervaults.config.annotation.Comment; +import com.drtshock.playervaults.config.annotation.ConfigName; import com.drtshock.playervaults.config.annotation.WipeOnReload; import com.drtshock.playervaults.lib.com.typesafe.config.Config; import com.drtshock.playervaults.lib.com.typesafe.config.ConfigFactory; @@ -27,8 +29,6 @@ import com.drtshock.playervaults.lib.com.typesafe.config.ConfigValueFactory; import com.drtshock.playervaults.lib.com.typesafe.config.ConfigValueType; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import com.drtshock.playervaults.config.annotation.Comment; -import com.drtshock.playervaults.config.annotation.ConfigName; import java.io.File; import java.io.IOException; @@ -91,7 +91,11 @@ public class Loader { Loader.types.add(String.class); } - private static @NonNull ConfigValue loadNode(@NonNull Config current, @NonNull Object object) throws IllegalAccessException { + private static @NonNull ConfigValue loadNode(@NonNull Config config, @NonNull Object object) throws IllegalAccessException { + return loadNode(config, "", object); + } + + private static @NonNull ConfigValue loadNode(@NonNull Config config, String path, @NonNull Object object) throws IllegalAccessException { Map map = new HashMap<>(); for (Field field : Loader.getFields(object.getClass())) { if (field.isSynthetic()) { @@ -108,7 +112,8 @@ public class Loader { ConfigName configName = field.getAnnotation(ConfigName.class); Comment comment = field.getAnnotation(Comment.class); String confName = configName == null || configName.value().isEmpty() ? field.getName() : configName.value(); - ConfigValue curValue = Loader.getOrNull(current, confName); + String newPath = path.isEmpty() ? confName : (path + '.' + confName); + ConfigValue curValue = Loader.getOrNull(config, newPath); boolean needsValue = curValue == null; ConfigValue newValue; @@ -131,7 +136,7 @@ public class Loader { } } } else { - newValue = Loader.loadNode(current, defaultValue); + newValue = Loader.loadNode(config, newPath, defaultValue); } if (comment != null) { newValue = newValue.withOrigin(newValue.origin().withComments(Arrays.asList(comment.value().split("\n"))));