Package commoble.databuddy.config

# Class ConfigHelper

java.lang.Object
commoble.databuddy.config.ConfigHelper

public class ConfigHelper extends Object
Helpers for creating configs and defining complex objects in configs

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static class`
`ConfigHelper.ConfigObject<T>`
A config-reload-sensitive wrapper around a config field for a complex object
`static class`
`ConfigHelper.TomlConfigOps`
DynamicOps for using `Codec`s to load objects from configs.

## Method Summary

Modifier and Type
Method
Description
`static <T> ConfigHelper.ConfigObject<T>`
`defineObject(net.minecraftforge.common.ForgeConfigSpec.Builder builder, String name, com.mojang.serialization.Codec<T> codec, T defaultObject)`
Define a config value for a complex object.
`static <T> T`
`register(net.minecraftforge.fml.config.ModConfig.Type configType, Function<net.minecraftforge.common.ForgeConfigSpec.Builder,T> configFactory)`
Register a config using a default config filename for your mod.
`static <T> T`
`register(net.minecraftforge.fml.config.ModConfig.Type configType, Function<net.minecraftforge.common.ForgeConfigSpec.Builder,T> configFactory, String configName)`
Register a config using a custom filename.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Method Details

### register

public static <T> T register(net.minecraftforge.fml.config.ModConfig.Type configType, Function<net.minecraftforge.common.ForgeConfigSpec.Builder,T> configFactory)
Register a config using a default config filename for your mod.

Type Parameters:
  `T` - The class of your config implementation
Parameters:
  `configType` - Forge config type:
  - SERVER configs are defined by the server and synced to clients; individual configs are generated per-save. Filename will be modid-server.toml
  - COMMON configs are definable by both server and clients and not synced (they may have different values). Filename will be modid-client.toml
  - CLIENT configs are defined by clients and not used on the server. Filename will be modid-client.toml.
  `configFactory` - A constructor or factory for your config class
Returns:
  An instance of your config class

### register

public static <T> T register(net.minecraftforge.fml.config.ModConfig.Type configType, Function<net.minecraftforge.common.ForgeConfigSpec.Builder,T> configFactory, @Nullable String configName)
Register a config using a custom filename.

Type Parameters:
  `T` - Your config class
Parameters:
  `configType` - Forge config type:
  - SERVER configs are defined by the server and synced to clients; individual configs are generated per-save.
  - COMMON configs are definable by both server and clients and not synced (they may have different values)
  - CLIENT configs are defined by clients and not used on the server
  `configFactory` - A constructor or factory for your config class
  `configName` - Name of your config file. Supports subfolders, e.g. "yourmod/yourconfig".
Returns:
  An instance of your config class

### defineObject

public static <T> ConfigHelper.ConfigObject<T> defineObject(net.minecraftforge.common.ForgeConfigSpec.Builder builder, String name, com.mojang.serialization.Codec<T> codec, T defaultObject)
Define a config value for a complex object.

Type Parameters:
  `T` - The type of the thing in the config we are making a listener for
Parameters:
  `builder` - Builder to build configs with
  `name` - The name of the field in your config that will hold objects of this type
  `codec` - A Codec for de/serializing your object type.
  `defaultObject` - The default instance of your config field. The given codec must be able to serialize this; if it cannot, an exception will be intentionally thrown the first time the config attempts to load. If the codec fails to deserialize the config field at a later time, an error message will be logged and this default instance will be used instead.
Returns:
  A reload-sensitive wrapper around your config object value. Use ConfigObject#get to get the most up-to-date object.