Class ConfigBuilder
java.lang.Object
my.celium.org.config.ConfigBuilder
Fluent builder for a mod's configuration.
Typical use (about ten lines):
ConfigBuilder builder = Mycel.config(META);
ConfigValue<Boolean> enabled = builder.booleanValue("enabled", true, "Whether the feature runs.");
ConfigValue<Integer> radius = builder.intValue("radius", 8, 1, 32, "Search radius in blocks.");
MycelConfig config = builder.build();
Call category(String) to scope subsequent values into a named
section (stored as a nested JSON object). Call root() to return to
the top level. A builder is single-use: build() may be called once.
-
Constructor Summary
ConstructorsConstructorDescriptionConfigBuilder(ModMetadata metadata) Creates a builder; preferMycel.config(...). -
Method Summary
Modifier and TypeMethodDescriptionbooleanValue(String key, boolean defaultValue, String description) build()Finalises the config: loadsconfig/<modid>.jsonand returns the live handle.Scopes subsequently defined values intoname(letters, digits,_-only).doubleValue(String key, double defaultValue, double min, double max, String description) <E extends Enum<E>>
ConfigValue<E> Registers a migration applied to the raw file content when upgrading fromfromVersion.root()Returns to the root level.schemaVersion(int version) Declares the schema version of this config; defaults to1.stringListValue(String key, List<String> defaultValue, String description) stringValue(String key, String defaultValue, int maxLength, String description) stringValue(String key, String defaultValue, String description)
-
Constructor Details
-
ConfigBuilder
Creates a builder; preferMycel.config(...).
-
-
Method Details
-
category
Scopes subsequently defined values intoname(letters, digits,_-only). -
root
Returns to the root level. -
schemaVersion
Declares the schema version of this config; defaults to1. -
migrate
Registers a migration applied to the raw file content when upgrading fromfromVersion. Migrations run in ascending version order before values are parsed, so old files keep working. -
booleanValue
-
intValue
public ConfigValue<Integer> intValue(String key, int defaultValue, int min, int max, String description) -
longValue
public ConfigValue<Long> longValue(String key, long defaultValue, long min, long max, String description) -
doubleValue
public ConfigValue<Double> doubleValue(String key, double defaultValue, double min, double max, String description) -
stringValue
-
stringValue
public ConfigValue<String> stringValue(String key, String defaultValue, int maxLength, String description) -
enumValue
public <E extends Enum<E>> ConfigValue<E> enumValue(String key, Class<E> type, E defaultValue, String description) -
stringListValue
-
build
Finalises the config: loadsconfig/<modid>.jsonand returns the live handle.
-