Config

open class Config @JvmOverloads constructor(identifier: Identifier, val subfolder: String = "", val folder: String = identifier.namespace, val name: String = identifier.path) : Walkable, Translatable

Base Config class for use with FzzyConfig

Implement a subclass of this base class, and include the config options you want as public non-final properties ("vars"). Register your config in the ConfigApi to benefit from auto-syncing to clients, auto-GUI generation, automatic update saving, and more. Recommended registration pattern is

  • Kotlin:var myConfig = ConfigApi.registerAndLoadConfig { MyConfigClass() }

  • Java: MyConfig myConfig = ConfigApi.registerAndLoadConfig(() -> new MyConfig())

For version control support, annotate your config classes with a Version. As you update the config, update this version number and implement any needed manual adjustments to update

FzzyConfig can interact with three types of vars

  1. {Not Recommended} "Bare" properties. Your standard property (ex: var myOption = 5). These properties won't be validated, corrected, and won't show up in Config Guis. For an internal server-only setting, this may be an appropriate choice, but generally strongly recommended to use a Validation wrapper.

  2. {Recommended} ConfigSection. Inner "sections" of a Config. Can be used to organize related topics of a larger config. Interfaces with the auto-GUI system as a "sub-layer". A button will allow the user to drill down into the section, showing only the options for that section. Sections automatically de/serialize updated entries back to the server/clients like #3 below.

  3. {Recommended} ValidatedField properties, or custom Entry implementations. These properties offer a wide array of powerful benefits to the user and the implementer

  • Validation. Inputs are automatically validated

  • Correction. Invalid inputs are automatically corrected, reverted, or skipped.

  • Gui Support. FzzyConfigs auto-generated GUIs only take Entry's into account when building their GUI layers. The internal validation is used to build meaningful and helpful widgets with helpful tooltips and auto-suggestions, where possible. Entry's are auto-synced back to the server and other listening clients based on user permission level

Author

fzzyhmstrs

Since

0.2.0

Parameters

identifier

Identifier - The identifier of this config. Common groups of namespace will be the first "layer" of the Config GUI where applicable (all configs of the same namespace in one group), so it's recommended to use one unified namespace (modid, generally)

name

String, optional - the name of the config, this will be the file name (sans file extension). By default, this is defined from the path of the config identifier. NOTE: Do not add a file type to this name. That is done automatically where needed

folder

String, optional - the subfolder inside the root config folder the file will be saved in. By default, this is defined from the namespace of the config identifier. Can be "", which will put the file in the root config folder.

subfolder

String, optional - puts the config into a sub-subfolder inside the subfolder specified in folder. Does not affect ID or GUI layout

See also

Constructors

Link copied to clipboard
constructor(identifier: Identifier, subfolder: String = "", folder: String = identifier.namespace, name: String = identifier.path)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
open fun defaultPermLevel(): Int

The default vanilla permission level of entries in this config. Users will need to have at least this permission level to modify entries for synced configs except for entries that are me.fzzyhmstrs.fzzy_config.annotations.ClientModifiable or me.fzzyhmstrs.fzzy_config.annotations.NonSync

Link copied to clipboard
open fun description(fallback: String? = null): MutableText

The translated Text description from the descriptionKey. Falls back to an empty string so no tooltip is rendered.

Link copied to clipboard
fun getId(): Identifier

The identifier of this Config.

Link copied to clipboard

Whether this Translatable has a valid description

Link copied to clipboard

Whether this Translatable has a valid translation

Link copied to clipboard
open fun onSyncClient()

Runs on the logical client after a config is synced from the server. This occurs when the player is logging in and when datapacks are reloaded. This is distinct from onUpdateClient, which fires when changes are made to a config in-game, which are also synced. This is the initial sync of the entire config state.

Link copied to clipboard
open fun onSyncServer()

Runs on the logical server as config is about to be synced to a client. This occurs when the player is logging in and when datapacks are reloaded. This is distinct from onUpdateServer, which fires when changes are made to a config in-game, which are also synced. This is the initial sync of the entire config state.

Link copied to clipboard
open fun onUpdateClient()

Runs on the logical client after the config is updated. Typically, this is when the user closes the config screen or applies changes, but also occurs after a connected client recieves a S2C update. This is distinct from onSyncClient, which fires when the entire config state is synced on login/reload. This handles chnages made in-game.

Link copied to clipboard
open fun onUpdateServer(playerEntity: ServerPlayerEntity)

Runs on the logical server after an updated config is prepared for saving. Typically, this will be after a config update is received from a connected client, and that update passes permission checks.

Link copied to clipboard
fun save()

Saves the config to file.

Link copied to clipboard
open fun translation(fallback: String? = null): MutableText

The translated Text name from the translationKey. Falls back to the implementing classes Simple Name (non-translated)

Link copied to clipboard
open fun update(deserializedVersion: Int)

Paired with Version annotations to perform needed manual updating of an outdated Config.