Skip to content

Commit 690f938

Browse files
committed
put instance of config in the config class
1 parent 2921847 commit 690f938

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,14 @@ public class ExampleMod implements ClientModInitializer {
2020

2121
public static ExampleMod INSTANCE; // Adds the instance of the mod, so we can access other variables.
2222

23-
private static ExampleConfig config;
24-
2523
public ExampleMod() {
2624
INSTANCE = this;
2725
}
2826

2927
// Register the config and commands.
3028
@Override
3129
public void onInitializeClient() {
32-
config = new ExampleConfig();
30+
ExampleConfig.INSTANCE.preload();
3331
CommandManager.registerCommand(new ExampleCommand());
3432
}
35-
36-
public static ExampleConfig getConfig() {
37-
return config;
38-
}
3933
}

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)