Interface IConfigRegistration


@NonExtendable public interface IConfigRegistration
Creates config schemas and persistent sort orders for one mod.

Get an instance from Configs.forMod(String). Use a client schema for preferences shared across worlds, a client-per-world schema for preferences that should vary by world or multiplayer server, or a server schema for world-owned settings shared with connected clients. Add categories and values to the returned builder, then call IConfigSchemaBuilder.build().

Sorting configs are for persistent user-defined ordering of values discovered at runtime. Each schema and sorting config must use its own file; MezzConfig rejects duplicate paths before accessing them.

Since:
0.3.0
  • Method Details

    • createClientSchemaBuilder

      IConfigSchemaBuilder createClientSchemaBuilder(String configFileName, String localizationPath)
      Create a client config shared across worlds and server connections.

      MezzConfig first loads a distributable pack default, then any settings for this installation. The schema loads synchronously when built. On a dedicated server, the builder remains usable so common registration code can run, but the built schema is inactive, default-backed, and is not registered or connected to a file.

      Parameters:
      configFileName - relative file name inside the mod's client config directory
      localizationPath - translation key prefix for the config file
      Returns:
      client-owned schema builder
      Since:
      0.3.0
    • createClientSchemaBuilder

      IConfigSchemaBuilder createClientSchemaBuilder(Path configFile, String localizationPath)
      Create a client config stored at an explicit file path.

      Use this when the conventional client config directory is not appropriate. Otherwise, prefer createClientSchemaBuilder(String, String). The supplied path is the complete config file location; MezzConfig does not append the mod id, ownership, or file name or create a separate pack-default file. Relative paths are captured as normalized absolute paths when this method is called. On a dedicated server, the builder remains usable so common registration code can run, but the built schema is inactive, default-backed, and does not access the supplied location. Building the schema reads or creates the file synchronously and fails if the location is unavailable. Later edits update the in-memory values before a delayed save; a later filesystem failure does not roll back the edit or reach the original editing call.

      Parameters:
      configFile - complete path to the config file
      localizationPath - translation key prefix for the config file
      Returns:
      client-owned schema builder
      Since:
      0.5.0
    • createServerSchemaBuilder

      IConfigSchemaBuilder createServerSchemaBuilder(String configFileName, String localizationPath)
      Create a server-owned config stored with each world and synchronized to connected clients.

      The server loads the distributable default from the conventional config directory and the authoritative values from the active world's server config directory. Connected clients receive the server's effective values in memory. When a remote server does not have MezzConfig, the client-side schema remains inactive and returns its declared defaults.

      Parameters:
      configFileName - relative file name inside the mod's server config directories
      localizationPath - translation key prefix for the config file
      Returns:
      server-owned schema builder
      Since:
      0.3.0
    • createClientPerWorldSchemaBuilder

      IConfigSchemaBuilder createClientPerWorldSchemaBuilder(String configFileName, String localizationPath)
      Create a client config with separate values for each singleplayer world or multiplayer server.

      Use this for client preferences that should follow the current world or server instead of the whole installation. A server with MezzConfig supplies a stable identity stored with its world. For vanilla and other unsupported servers, MezzConfig falls back to the name and address available to the client. On a dedicated server, the builder remains usable so common registration code can run, but the built schema is inactive, default-backed, and is not registered or connected to a file.

      Parameters:
      configFileName - relative file name inside the mod's client-world config directories
      localizationPath - translation key prefix for the config file
      Returns:
      client-owned world schema builder
      Since:
      0.3.0
    • createSortingConfig

      ISortingConfig<String> createSortingConfig(String configFileName, Comparator<String> defaultSortOrder, boolean allowsRemovingValues)
      Create a persistent user-defined order for strings discovered at runtime. On a dedicated server, the sort order remains in memory and does not access a file.
      Parameters:
      configFileName - relative file name inside the mod's client config directory
      defaultSortOrder - default order for values that are not in the file yet
      allowsRemovingValues - whether values may be removed from this sort order
      Returns:
      the created sort order
      Throws:
      IllegalArgumentException - when the sort order's file path is already reserved
      Since:
      0.3.0
    • createSortingConfig

      <T> ISortingConfig<T> createSortingConfig(String configFileName, IConfigValueSerializer<T> serializer, Comparator<T> defaultSortOrder, boolean allowsRemovingValues)
      Create a persistent user-defined order for mod-specific values discovered at runtime. On a dedicated server, the sort order remains in memory and does not access a file. Every sortable value must be valid for the serializer and round-trip to an equal value without diagnostics. The serialized text is its persistent identity, so equal values must serialize identically and unequal values must not share serialized text.
      Type Parameters:
      T - effectively immutable sortable value type
      Parameters:
      configFileName - relative file name inside the mod's client config directory
      serializer - serializer defining validation and persistent identities for sortable values
      defaultSortOrder - default order for values that are not in the file yet
      allowsRemovingValues - whether values may be removed from this sort order
      Returns:
      the created sort order
      Throws:
      IllegalArgumentException - when the sort order's file path is already reserved
      Since:
      0.3.0