Package commoble.databuddy.config

# Class ConfigHelper.Subscriber

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

Enclosing class:
  ConfigHelper

public static class ConfigHelper.Subscriber extends Object
Subscriber instances are given to your config class's constructor

## Method Summary

Modifier and Type
Method
Description
`<T> ConfigHelper.ConfigValueListener<T>`
`subscribe​(net.minecraftforge.common.ForgeConfigSpec.ConfigValue<T> value)`
Subscribe a config value to the config reload event.
`<T> ConfigHelper.ConfigObjectListener<T>`
`subscribeObject​(net.minecraftforge.common.ForgeConfigSpec.Builder builder, String name, com.mojang.serialization.Codec<T> codec, T defaultObject)`
Subscribe a config value for a complex object type to the config reload event.

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

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

## Method Details

### subscribe

public <T> ConfigHelper.ConfigValueListener<T> subscribe​(net.minecraftforge.common.ForgeConfigSpec.ConfigValue<T> value)
Subscribe a config value to the config reload event. Use with a forge config builder to create the config values.

Type Parameters:
  `T` - The type of the value the config value is configuring
Parameters:
  `value` - The config value we are subscribing
Returns:
  A reload-sensitive wrapper around your config value. Use listener.get() to get the most up-to-date value.

### subscribeObject

public <T> ConfigHelper.ConfigObjectListener<T> subscribeObject​(net.minecraftforge.common.ForgeConfigSpec.Builder builder, String name, com.mojang.serialization.Codec<T> codec, T defaultObject)
Subscribe a config value for a complex object type to the config reload event. This is an experimental new feature and may not work correctly or at all with all types of objects.

Type Parameters:
  `T` - The type of the thing in the config we are making a listener for
Parameters:
  `builder` - the forge config builder
  `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. See drullkus's codec primer for guiding of the creation of these:
  https://gist.github.com/Drullkus/1bca3f2d7f048b1fe03be97c28f87910
  `defaultObject` - The default instance of your config field. The given codec must be able to serialize this; if it cannot, a RunTimeException 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 listener.get() to get the most up-to-date object.