Skip to content

Commit 17121e4

Browse files
committed
put instance of config in the config class
1 parent 3985a21 commit 17121e4

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

src/main/java/org/polyfrost/example/ExampleMod.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,10 @@ public class ExampleMod {
2323
@Mod.Instance(ID)
2424
public static ExampleMod INSTANCE; // Adds the instance of the mod, so we can access other variables.
2525

26-
private static ExampleConfig config;
27-
2826
// Register the config and commands.
2927
@Mod.EventHandler
3028
public void onInit(FMLInitializationEvent event) {
31-
config = new ExampleConfig();
29+
ExampleConfig.INSTANCE.preload();
3230
CommandManager.registerCommand(new ExampleCommand());
3331
}
34-
35-
public static ExampleConfig getConfig() {
36-
return config;
37-
}
38-
3932
}

src/main/java/org/polyfrost/example/command/ExampleCommand.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.polyfrost.example.command;
22

33
import org.polyfrost.example.ExampleMod;
4+
import org.polyfrost.example.config.ExampleConfig;
45
import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.Command;
56
import org.polyfrost.oneconfig.utils.v1.dsl.ScreensKt;
67

@@ -16,7 +17,7 @@ public class ExampleCommand {
1617

1718
@Command
1819
private void main() {
19-
ScreensKt.openUI(ExampleMod.getConfig());
20+
ScreensKt.openUI(ExampleConfig.INSTANCE);
2021
}
2122

2223
}

src/main/java/org/polyfrost/example/config/ExampleConfig.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public class ExampleConfig extends Config {
2828
)
2929
public static int exampleDropdown = 1; // Default option (in this case "Option 2")
3030

31+
public static final ExampleConfig INSTANCE = new ExampleConfig(); // The instance of the config.
32+
3133
public ExampleConfig() {
3234
super(ExampleMod.ID + ".json", ExampleMod.NAME, Category.OTHER); // TODO: Change your category here.
3335
}

0 commit comments

Comments
 (0)