Config Options
Here you will learn how to create options inside OneConfig.
Adding options
Creation
Options are added with Java annotations. Any field you annotate with an option will be saved to your config file, which you earlier specified in it's constructor. It'll then be displayed to the user within the OneConfig GUI.
@Switch(
name = "A random switch",
size = OptionSize.DUAL, // optional, declares whether the element is single column or dual column
category = "General", // optional
subcategory = "Switches" // optional
)
public static boolean bob = false; // this is the default value.
Accessing
Retrieving the value of your options is incredibly easy, as seen in the example below!
System.out.println("My thing in a variable called bob: " + MyConfig.bob);
System.out.println("Is this enabled? " + MyConfig.enabled);
Disabling Options
Disabled options are still visible to the user, but cannot be interacted with. You can disable them by adding dependencies.
If you wish to do this, go back to your config's constructer, and put in an addDependency
line, as seen below. The first argument will specify which variable should be edited, given the value of the second argument.
@Switch(
name = "Master Switch",
size = OptionSize.DUAL
)
public static boolean masterSwitch = false;
@Switch(
name = "Sub Switch",
type = OptionType.SWITCH,
)
public static boolean subSwitch = false;
public TestConfig() {
super(new Mod("My Mod", ModType.UTIL_QOL), "mymod.json");
addDependency("subSwitch", () -> masterSwitch); // disable subSwitch if masterSwitch is off, making it dependant
}
Other option features
Sizes
Options come in two sizes in the GUI, SINGLE
and DUAL
. These are stored in a simple enum called OptionSize
. Here is what a single and dual Text Field look like:

Option types
There are lots to choose from, so what are you waiting for?
Boolean ConfigsNumber ConfigsSelector ConfigsText ConfigsButtons, Colors and KeybindsDecorative ComponentsLast updated
Was this helpful?