Class ConfigBuilder

java.lang.Object
my.celium.org.config.ConfigBuilder

public final class ConfigBuilder extends Object
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 Details

    • ConfigBuilder

      public ConfigBuilder(ModMetadata metadata)
      Creates a builder; prefer Mycel.config(...).
  • Method Details

    • category

      public ConfigBuilder category(String name)
      Scopes subsequently defined values into name (letters, digits, _- only).
    • root

      public ConfigBuilder root()
      Returns to the root level.
    • schemaVersion

      public ConfigBuilder schemaVersion(int version)
      Declares the schema version of this config; defaults to 1.
    • migrate

      public ConfigBuilder migrate(int fromVersion, Consumer<com.google.gson.JsonObject> migration)
      Registers a migration applied to the raw file content when upgrading from fromVersion. Migrations run in ascending version order before values are parsed, so old files keep working.
    • booleanValue

      public ConfigValue<Boolean> booleanValue(String key, boolean defaultValue, String description)
    • 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

      public ConfigValue<String> stringValue(String key, String defaultValue, String description)
    • 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

      public ConfigValue<List<String>> stringListValue(String key, List<String> defaultValue, String description)
    • build

      public MycelConfig build()
      Finalises the config: loads config/<modid>.json and returns the live handle.