Interface ModConfig


@NonExtendable public interface ModConfig
Settings of one mod: <forge>/mods/<id>/config.toml, over the defaults in the mod's jar (META-INF/zomboidforge/config.toml). A key missing from the file takes the default. The table [forge] belongs to ZomboidForge and is not part of these settings.

Keys are snake_case; record components and paths use the same names converted from camelCase (maxBalance reads max_balance), or the name of the component's Key.

  • Method Summary

    Modifier and Type
    Method
    Description
    <T extends Record>
    T
    bind(Class<T> type)
    Creates a record from the settings.
    <T> Optional<T>
    get(String path, Class<T> type)
    The value at a dotted path, e.g.
  • Method Details

    • bind

      <T extends Record> T bind(Class<T> type)
      Creates a record from the settings. Supported component types: String, boolean, int, long, float, double (and their wrappers), enums (by constant name), records (TOML tables), List<T>, Map<String, T> (tables with free keys), and Optional<T> for values that may be missing. Every other component must have a value. Keys without a component are logged as warnings. Min and Max bound numeric components.
      Throws:
      IllegalStateException - listing every missing, mistyped, or out-of-bounds value
      IllegalArgumentException - when type has a component that configuration values cannot have, an invalid or repeated Key, or Min/Max on a component that is not numeric or with the minimum above the maximum
    • get

      <T> Optional<T> get(String path, Class<T> type)
      The value at a dotted path, e.g. "features.max_balance", converted like a record component of type. Primitive values use the wrapper types (Long.class).
      Throws:
      IllegalStateException - when the value exists but has another type