diff options
author | isXander <xandersmith2008@gmail.com> | 2023-08-12 23:56:06 +0100 |
---|---|---|
committer | isXander <xandersmith2008@gmail.com> | 2023-08-12 23:56:06 +0100 |
commit | d37e147dbb4db44a921533b572aed3e54b5c6a42 (patch) | |
tree | 0c72e58da081135d3819c4af7365f08c2af7fdb6 /test-common/src/main/java | |
parent | 3083aebe47f63661238ee2b521b0451af2d95e9f (diff) | |
download | YetAnotherConfigLib-d37e147dbb4db44a921533b572aed3e54b5c6a42.tar.gz YetAnotherConfigLib-d37e147dbb4db44a921533b572aed3e54b5c6a42.tar.bz2 YetAnotherConfigLib-d37e147dbb4db44a921533b572aed3e54b5c6a42.zip |
Config API v2
Diffstat (limited to 'test-common/src/main/java')
-rw-r--r-- | test-common/src/main/java/dev/isxander/yacl3/test/ConfigTest.java | 14 | ||||
-rw-r--r-- | test-common/src/main/java/dev/isxander/yacl3/test/GuiTest.java | 3 |
2 files changed, 10 insertions, 7 deletions
diff --git a/test-common/src/main/java/dev/isxander/yacl3/test/ConfigTest.java b/test-common/src/main/java/dev/isxander/yacl3/test/ConfigTest.java index 3b5c8a5..3a057f9 100644 --- a/test-common/src/main/java/dev/isxander/yacl3/test/ConfigTest.java +++ b/test-common/src/main/java/dev/isxander/yacl3/test/ConfigTest.java @@ -1,16 +1,18 @@ package dev.isxander.yacl3.test; -import dev.isxander.yacl3.config.ConfigEntry; -import dev.isxander.yacl3.config.ConfigInstance; -import dev.isxander.yacl3.config.GsonConfigInstance; +import dev.isxander.yacl3.config.v2.api.ConfigClassHandler; +import dev.isxander.yacl3.config.v2.api.ConfigEntry; +import dev.isxander.yacl3.config.v2.api.GsonConfigSerializerBuilder; +import dev.isxander.yacl3.platform.YACLPlatform; import java.awt.*; import java.util.List; -import java.nio.file.Path; public class ConfigTest { - public static final ConfigInstance<ConfigTest> GSON = GsonConfigInstance.createBuilder(ConfigTest.class) - .setPath(Path.of("./config/yacl-test.json")) + public static final ConfigClassHandler<ConfigTest> GSON = ConfigClassHandler.createBuilder(ConfigTest.class) + .serializer(config -> GsonConfigSerializerBuilder.create(config) + .setPath(YACLPlatform.getConfigDir().resolve("yacl-test.json")) + .build()) .build(); @ConfigEntry public boolean booleanToggle = false; diff --git a/test-common/src/main/java/dev/isxander/yacl3/test/GuiTest.java b/test-common/src/main/java/dev/isxander/yacl3/test/GuiTest.java index c490799..71e5545 100644 --- a/test-common/src/main/java/dev/isxander/yacl3/test/GuiTest.java +++ b/test-common/src/main/java/dev/isxander/yacl3/test/GuiTest.java @@ -57,6 +57,7 @@ public class GuiTest { private static Screen getFullTestSuite(Screen parent) { AtomicReference<Option<Boolean>> booleanOption = new AtomicReference<>(); + ConfigTest.GSON.serializer().deserialize(); return YetAnotherConfigLib.create(ConfigTest.GSON, (defaults, config, builder) -> builder .title(Component.literal("Test GUI")) .category(ConfigCategory.createBuilder() @@ -372,7 +373,7 @@ public class GuiTest { .build()) .save(() -> { Minecraft.getInstance().options.save(); - ConfigTest.GSON.save(); + ConfigTest.GSON.serializer().serialize(); }) ) .generateScreen(parent); |