Getting Started
Bento Config is an annotation-driven configuration system built using Bento GUI. It aims to be simple yet powerful, with no magic pre-processors or arbitrary limitations. Adding descriptions and comments to options is as simple as adding a translation key, and even images are automatically sourced from the assets folder.
Quick Start
Section titled “Quick Start”-
Include my maven in the
repositoriesblock of your build file:build.gradle repositories {maven {name "Chai's Maven"url "https://codeberg.org/api/packages/chai/maven"}}build.gradle.kts repositories {maven("https://codeberg.org/api/packages/chai/maven") {name = "Chai's Maven"}} -
Declare the dependency in your
dependenciesblock:build.gradle dependencies {modImplementation "dev.chailotl:bento-config:${project.bento_config_version}"} -
Add the version you want to use in your
gradle.propertiesfile:gradle.properties bento_config_version=0.1.0+1.21
Create your config
Section titled “Create your config”To get started with creating your config, make a class that extends BentoConfig<T> where T is your config class.
public class MyConfig extends BentoConfig<MyConfig> { ...}Then, you add options to your config by simply adding fields to your class.
public class MyConfig extends BentoConfig<MyConfig> { public boolean aBooleanOption = true; public int anIntOption = 64; public Style anEnumOption = Style.CUTE;
public enum Style { CUTE, COOL }}And lastly, you register your config in your mod initializer using your mod ID.
public class MyModInitializer implements ModInitializer { ... public static final MyConfig CONFIG = new MyConfig.register("my_mod_id"); ...}Your config is now ready to be used anywhere! If you programatically modify an option, be sure to run save() on your config.
Translations
Section titled “Translations”Each option’s translation key is generated based on its field name and the residing config’s mod ID. The generated keys take the form config.<MOD_ID>.option.<OPTION_NAME>.
To add a description to an option, simply add a translation for the config.<MOD_ID>.description.<OPTION_NAME> key, and it will automatically show up in the sidebar. This translation supports \n line breaks.
To add a comment to an option, add a translation for the config.<MOD_ID>.comment.<OPTION_NAME> key, and it will automatically show up in the config file. If the option does not have a description, it will also use this key.
Optionally, you can also add translation keys for enums like so: config.<MOD_ID>.enum.<ENUM_NAME>.<ENUM_VALUE>. The enum name and value is case-sensitive, so if your enum is Style.COOL, then the key would be config.my_mod_id.enum.Style.COOL.
And let’s not forget the title of your config screen is config.<MOD_ID>.title!
Images
Section titled “Images”To add images to your options, simply place a PNG image at this location assets/<MOD_ID>/textures/config/<OPTION_NAME>.png, and it will automatically show up in the sidebar. That’s it!
Organizing the config screen
Section titled “Organizing the config screen”As you add more options, you may want to organize things with headers, paragraphs, and spaces.
To add a header, simply apply the @Header annotation to the field which you want to place the header above. If you want a paragraph or a space instead, apply the @Paragraph or @Space annotations instead.
You can combine all three on the same field, and they will render in this order in the config screen:
- Space
- Header
- Paragraph
Example:
public class MyConfig extends BentoConfig<MyConfig> { public String firstOption = "Hello";
@Header("first_header") public String secondOption = "world!";
@Header("second_header") @Paragraph("second_paragraph") public String thirdOption = "Uh oh";
@Space() public String fourthOption = "what do I say now?";}