Package net.neoforged.neoforge.common
Class ModConfigSpec.ConfigValue<T>
java.lang.Object
net.neoforged.neoforge.common.ModConfigSpec.ConfigValue<T>
- All Implemented Interfaces:
Supplier<T>
- Direct Known Subclasses:
ModConfigSpec.BooleanValue
,ModConfigSpec.DoubleValue
,ModConfigSpec.EnumValue
,ModConfigSpec.IntValue
,ModConfigSpec.LongValue
- Enclosing class:
ModConfigSpec
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate T
private final ModConfigSpec.Builder
private @Nullable ModConfigSpec
-
Constructor Summary
ConstructorsConstructorDescriptionConfigValue
(ModConfigSpec.Builder parent, List<String> path, Supplier<T> defaultSupplier) -
Method Summary
Modifier and TypeMethodDescriptionvoid
get()
Returns the configured value for the configuration setting, throwing if the config has not yet been loaded.Returns the default value for the configuration setting.getPath()
getRaw()
Returns the uncached value for the configuration setting, throwing if the config has not yet been loaded.getRaw
(com.electronwill.nightconfig.core.Config config, List<String> path, Supplier<T> defaultSupplier) getSpec()
next()
void
save()
void
Directly sets the value, without firing events or writing the config to disk.
-
Field Details
-
parent
-
path
-
defaultSupplier
-
cachedValue
-
spec
-
-
Constructor Details
-
ConfigValue
ConfigValue(ModConfigSpec.Builder parent, List<String> path, Supplier<T> defaultSupplier)
-
-
Method Details
-
getPath
-
get
Returns the configured value for the configuration setting, throwing if the config has not yet been loaded.This getter is cached, and will respect the
world restart
andgame restart
options by not clearing its cache if one of those options are set.- Specified by:
get
in interfaceSupplier<T>
- Returns:
- the configured value for the setting
- Throws:
NullPointerException
- if theconfig spec
object that will contain this has not yet been builtIllegalStateException
- if the associated config has not yet been loaded
-
getRaw
Returns the uncached value for the configuration setting, throwing if the config has not yet been loaded.Do not call this for any other purpose than editing the value. Use
get()
instead. -
getRaw
-
getDefault
Returns the default value for the configuration setting.- Returns:
- the default value for the configuration setting
-
next
-
save
public void save() -
set
Directly sets the value, without firing events or writing the config to disk. Make sure to callModConfigSpec.save()
eventually. -
getSpec
-
clearCache
public void clearCache()
-