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 3985a21 commit 17121e4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
9 changes: 1 addition & 8 deletions src/main/java/org/polyfrost/example/ExampleMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,10 @@ public class ExampleMod {
@Mod.Instance(ID)
public static ExampleMod INSTANCE; // Adds the instance of the mod, so we can access other variables.

private static ExampleConfig config;

// Register the config and commands.
@Mod.EventHandler
public void onInit(FMLInitializationEvent event) {
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 17121e4

Please sign in to comment.