aboutsummaryrefslogtreecommitdiff
path: root/src/testmod
diff options
context:
space:
mode:
authorisXander <xandersmith2008@gmail.com>2022-12-11 12:55:34 +0000
committerisXander <xandersmith2008@gmail.com>2022-12-11 12:55:34 +0000
commitc1afd0716e34f042d3c8a0df5211a5e3f2dec801 (patch)
treefe35bb773c1e14129842b95d1f7c92c537da300e /src/testmod
parent666cd10b4ea277639d2c8249a90221499112be93 (diff)
downloadYetAnotherConfigLib-c1afd0716e34f042d3c8a0df5211a5e3f2dec801.tar.gz
YetAnotherConfigLib-c1afd0716e34f042d3c8a0df5211a5e3f2dec801.tar.bz2
YetAnotherConfigLib-c1afd0716e34f042d3c8a0df5211a5e3f2dec801.zip
generify testmod so people can use it as an example
Diffstat (limited to 'src/testmod')
-rw-r--r--src/testmod/java/dev/isxander/yacl/test/ExampleMod.java11
-rw-r--r--src/testmod/java/dev/isxander/yacl/test/config/Entrypoint.java20
-rw-r--r--src/testmod/java/dev/isxander/yacl/test/config/ExampleConfig.java (renamed from src/testmod/java/dev/isxander/yacl/test/config/ConfigData.java)7
-rw-r--r--src/testmod/java/dev/isxander/yacl/test/config/GuiTest.java (renamed from src/testmod/java/dev/isxander/yacl/test/GuiTest.java)19
-rw-r--r--src/testmod/java/dev/isxander/yacl/test/mixins/TitleScreenMixin.java6
-rw-r--r--src/testmod/resources/fabric.mod.json2
6 files changed, 32 insertions, 33 deletions
diff --git a/src/testmod/java/dev/isxander/yacl/test/ExampleMod.java b/src/testmod/java/dev/isxander/yacl/test/ExampleMod.java
new file mode 100644
index 0000000..46c5225
--- /dev/null
+++ b/src/testmod/java/dev/isxander/yacl/test/ExampleMod.java
@@ -0,0 +1,11 @@
+package dev.isxander.yacl.test;
+
+import dev.isxander.yacl.test.config.ExampleConfig;
+import net.fabricmc.api.ClientModInitializer;
+
+public class ExampleMod implements ClientModInitializer {
+ @Override
+ public void onInitializeClient() {
+ ExampleConfig.INSTANCE.load();
+ }
+}
diff --git a/src/testmod/java/dev/isxander/yacl/test/config/Entrypoint.java b/src/testmod/java/dev/isxander/yacl/test/config/Entrypoint.java
deleted file mode 100644
index c71f592..0000000
--- a/src/testmod/java/dev/isxander/yacl/test/config/Entrypoint.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package dev.isxander.yacl.test.config;
-
-import dev.isxander.yacl.config.ConfigInstance;
-import dev.isxander.yacl.config.GsonConfigInstance;
-import net.fabricmc.api.ClientModInitializer;
-import net.fabricmc.loader.api.FabricLoader;
-
-public class Entrypoint implements ClientModInitializer {
- private static ConfigInstance<ConfigData> config;
-
- @Override
- public void onInitializeClient() {
- config = new GsonConfigInstance<>(ConfigData.class, FabricLoader.getInstance().getConfigDir().resolve("yacl-test.json"));
- config.load();
- }
-
- public static ConfigInstance<ConfigData> getConfig() {
- return config;
- }
-}
diff --git a/src/testmod/java/dev/isxander/yacl/test/config/ConfigData.java b/src/testmod/java/dev/isxander/yacl/test/config/ExampleConfig.java
index 4eedd9f..c7ea46c 100644
--- a/src/testmod/java/dev/isxander/yacl/test/config/ConfigData.java
+++ b/src/testmod/java/dev/isxander/yacl/test/config/ExampleConfig.java
@@ -1,10 +1,15 @@
package dev.isxander.yacl.test.config;
import dev.isxander.yacl.config.ConfigEntry;
+import dev.isxander.yacl.config.ConfigInstance;
+import dev.isxander.yacl.config.GsonConfigInstance;
import java.awt.*;
+import java.nio.file.Path;
+
+public class ExampleConfig {
+ public static final ConfigInstance<ExampleConfig> INSTANCE = new GsonConfigInstance<>(ExampleConfig.class, Path.of("./config/yacl-test.json"));
-public class ConfigData {
@ConfigEntry public boolean booleanToggle = false;
@ConfigEntry public boolean customBooleanToggle = false;
@ConfigEntry public boolean tickbox = false;
diff --git a/src/testmod/java/dev/isxander/yacl/test/GuiTest.java b/src/testmod/java/dev/isxander/yacl/test/config/GuiTest.java
index 492a573..7295f2c 100644
--- a/src/testmod/java/dev/isxander/yacl/test/GuiTest.java
+++ b/src/testmod/java/dev/isxander/yacl/test/config/GuiTest.java
@@ -1,4 +1,4 @@
-package dev.isxander.yacl.test;
+package dev.isxander.yacl.test.config;
import dev.isxander.yacl.api.*;
import dev.isxander.yacl.gui.RequireRestartScreen;
@@ -13,8 +13,7 @@ import dev.isxander.yacl.gui.controllers.string.number.DoubleFieldController;
import dev.isxander.yacl.gui.controllers.string.number.FloatFieldController;
import dev.isxander.yacl.gui.controllers.string.number.IntegerFieldController;
import dev.isxander.yacl.gui.controllers.string.number.LongFieldController;
-import dev.isxander.yacl.test.config.ConfigData;
-import dev.isxander.yacl.test.config.Entrypoint;
+import dev.isxander.yacl.test.ExampleMod;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.option.GraphicsMode;
@@ -27,7 +26,7 @@ import java.awt.*;
public class GuiTest {
public static Screen getModConfigScreenFactory(Screen parent) {
- return YetAnotherConfigLib.create(Entrypoint.getConfig(), (defaults, config, builder) -> builder
+ return YetAnotherConfigLib.create(ExampleConfig.INSTANCE, (defaults, config, builder) -> builder
.title(Text.of("Test Suites"))
.category(ConfigCategory.createBuilder()
.name(Text.of("Suites"))
@@ -57,7 +56,7 @@ public class GuiTest {
}
private static Screen getFullTestSuite(Screen parent) {
- return YetAnotherConfigLib.create(Entrypoint.getConfig(), (defaults, config, builder) -> builder
+ return YetAnotherConfigLib.create(ExampleConfig.INSTANCE, (defaults, config, builder) -> builder
.title(Text.of("Test GUI"))
.category(ConfigCategory.createBuilder()
.name(Text.of("Control Examples"))
@@ -202,7 +201,7 @@ public class GuiTest {
.build())
.group(OptionGroup.createBuilder()
.name(Text.of("Enum Controllers"))
- .option(Option.createBuilder(ConfigData.Alphabet.class)
+ .option(Option.createBuilder(ExampleConfig.Alphabet.class)
.name(Text.of("Enum Cycler"))
.binding(
defaults.enumOption,
@@ -374,14 +373,14 @@ public class GuiTest {
.build())
.save(() -> {
MinecraftClient.getInstance().options.write();
- Entrypoint.getConfig().save();
+ ExampleConfig.INSTANCE.save();
})
)
.generateScreen(parent);
}
private static Screen getDisabledTest(Screen parent) {
- return YetAnotherConfigLib.create(Entrypoint.getConfig(), (defaults, config, builder) -> builder
+ return YetAnotherConfigLib.create(ExampleConfig.INSTANCE, (defaults, config, builder) -> builder
.title(Text.empty())
.category(ConfigCategory.createBuilder()
.name(Text.of("Disabled Test"))
@@ -414,7 +413,7 @@ public class GuiTest {
}
private static Screen getWikiBasic(Screen parent) {
- return YetAnotherConfigLib.create(Entrypoint.getConfig(), (defaults, config, builder) -> builder
+ return YetAnotherConfigLib.create(ExampleConfig.INSTANCE, (defaults, config, builder) -> builder
.title(Text.of("Mod Name"))
.category(ConfigCategory.createBuilder()
.name(Text.of("My Category"))
@@ -435,7 +434,7 @@ public class GuiTest {
}
private static Screen getWikiGroups(Screen parent) {
- return YetAnotherConfigLib.create(Entrypoint.getConfig(), (defaults, config, builder) -> builder
+ return YetAnotherConfigLib.create(ExampleConfig.INSTANCE, (defaults, config, builder) -> builder
.title(Text.of("Mod Name"))
.category(ConfigCategory.createBuilder()
.name(Text.of("My Category"))
diff --git a/src/testmod/java/dev/isxander/yacl/test/mixins/TitleScreenMixin.java b/src/testmod/java/dev/isxander/yacl/test/mixins/TitleScreenMixin.java
index 2635eaf..2f65b96 100644
--- a/src/testmod/java/dev/isxander/yacl/test/mixins/TitleScreenMixin.java
+++ b/src/testmod/java/dev/isxander/yacl/test/mixins/TitleScreenMixin.java
@@ -1,6 +1,6 @@
package dev.isxander.yacl.test.mixins;
-import dev.isxander.yacl.test.GuiTest;
+import dev.isxander.yacl.test.config.GuiTest;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.TitleScreen;
import net.minecraft.client.gui.widget.ButtonWidget;
@@ -10,6 +10,10 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+/**
+ * For testing purposes! If you are using this as
+ * an example, ignore this class!
+ */
@Mixin(TitleScreen.class)
public abstract class TitleScreenMixin extends Screen {
protected TitleScreenMixin(Text title) {
diff --git a/src/testmod/resources/fabric.mod.json b/src/testmod/resources/fabric.mod.json
index 5fe0919..d682084 100644
--- a/src/testmod/resources/fabric.mod.json
+++ b/src/testmod/resources/fabric.mod.json
@@ -10,7 +10,7 @@
"environment": "client",
"entrypoints": {
"client": [
- "dev.isxander.yacl.test.config.Entrypoint"
+ "dev.isxander.yacl.test.ExampleMod"
]
},
"depends": {