Skip to content

Commit

Permalink
put instance of config in the config class
Browse files Browse the repository at this point in the history
  • Loading branch information
Wyvest committed Jan 1, 2025
1 parent 2921847 commit 690f938
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
8 changes: 1 addition & 7 deletions src/main/java/org/polyfrost/example/ExampleMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,14 @@ public class ExampleMod implements ClientModInitializer {

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

private static ExampleConfig config;

public ExampleMod() {
INSTANCE = this;
}

// Register the config and commands.
@Override
public void onInitializeClient() {
config = new ExampleConfig();
ExampleConfig.INSTANCE.preload();
CommandManager.registerCommand(new ExampleCommand());
}

public static ExampleConfig getConfig() {
return config;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.polyfrost.example.command;

import org.polyfrost.example.ExampleMod;
import org.polyfrost.example.config.ExampleConfig;
import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.Command;
import org.polyfrost.oneconfig.utils.v1.dsl.ScreensKt;

Expand All @@ -16,7 +17,7 @@ public class ExampleCommand {

@Command
private void main() {
ScreensKt.openUI(ExampleMod.getConfig());
ScreensKt.openUI(ExampleConfig.INSTANCE);
}

}
2 changes: 2 additions & 0 deletions src/main/java/org/polyfrost/example/config/ExampleConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public class ExampleConfig extends Config {
)
public static int exampleDropdown = 1; // Default option (in this case "Option 2")

public static final ExampleConfig INSTANCE = new ExampleConfig(); // The instance of the config.

public ExampleConfig() {
super(ExampleMod.ID + ".json", ExampleMod.NAME, Category.OTHER); // TODO: Change your category here.
}
Expand Down

0 comments on commit 690f938

Please sign in to comment.