Package net.neoforged.fml.config
Class ConfigTracker
java.lang.Object
net.neoforged.fml.config.ConfigTracker
The configuration tracker manages various types of mod configurations.
Due to the parallel nature of mod initialization, modifying the configuration state must be thread-safe.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final org.slf4j.Marker
(package private) final ConcurrentHashMap
<String, List<ModConfig>> (package private) final EnumMap
<ModConfig.Type, Set<ModConfig>> private static final Path
(package private) final ConcurrentHashMap
<String, ModConfig> static final ConfigTracker
private final Map
<String, ReentrantLock> private static final org.slf4j.Logger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
acceptSyncedConfig
(ModConfig modConfig, byte[] bytes) private static void
backUpConfig
(Path commentedFileConfig) private static void
backUpConfig
(Path commentedFileConfig, int maxBackups) private static com.electronwill.nightconfig.core.CommentedConfig
private static String
defaultConfigName
(ModConfig.Type type, String modId) (package private) static void
loadConfig
(ModConfig modConfig, Path path, Function<ModConfig, ModConfigEvent> eventConstructor) void
loadConfigs
(ModConfig.Type type, Path configBasePath) void
loadConfigs
(ModConfig.Type type, Path configBasePath, @Nullable Path configOverrideBasePath) void
(package private) static void
openConfig
(ModConfig config, Path configBasePath, @Nullable Path configOverrideBasePath) private static com.electronwill.nightconfig.core.concurrent.ConcurrentCommentedConfig
readConfig
(Path path) registerConfig
(ModConfig.Type type, IConfigSpec spec, ModContainer container) Registers a new configuration of the given type for a mod, using the default filename for this type of config.registerConfig
(ModConfig.Type type, IConfigSpec spec, ModContainer container, String fileName) Registers a new configuration of the given type for a mod, using a custom filename.private static Path
resolveBasePath
(ModConfig config, Path configBasePath, @Nullable Path configOverrideBasePath) private static void
setupConfigFile
(ModConfig modConfig, Path file) (package private) void
trackConfig
(ModConfig config) private static void
private static void
unloadConfig
(ModConfig config) void
unloadConfigs
(ModConfig.Type type) (package private) static void
writeConfig
(Path file, com.electronwill.nightconfig.core.UnmodifiableCommentedConfig config)
-
Field Details
-
INSTANCE
-
CONFIG
static final org.slf4j.Marker CONFIG -
LOGGER
private static final org.slf4j.Logger LOGGER -
defaultConfigPath
-
fileMap
-
configSets
-
configsByMod
-
locksByMod
-
-
Constructor Details
-
ConfigTracker
@VisibleForTesting public ConfigTracker()
-
-
Method Details
-
registerConfig
Registers a new configuration of the given type for a mod, using the default filename for this type of config.Registering a configuration is required to receive configuration events.
-
registerConfig
public ModConfig registerConfig(ModConfig.Type type, IConfigSpec spec, ModContainer container, String fileName) Registers a new configuration of the given type for a mod, using a custom filename.Registering a configuration is required to receive configuration events.
-
defaultConfigName
-
trackConfig
-
loadConfigs
-
loadConfigs
public void loadConfigs(ModConfig.Type type, Path configBasePath, @Nullable @Nullable Path configOverrideBasePath) -
unloadConfigs
-
openConfig
-
resolveBasePath
-
loadConfig
static void loadConfig(ModConfig modConfig, Path path, Function<ModConfig, ModConfigEvent> eventConstructor) -
acceptSyncedConfig
-
loadDefaultServerConfigs
public void loadDefaultServerConfigs() -
createDefaultConfig
private static com.electronwill.nightconfig.core.CommentedConfig createDefaultConfig(IConfigSpec spec) -
unloadConfig
-
unload
-
setupConfigFile
- Throws:
IOException
-
readConfig
private static com.electronwill.nightconfig.core.concurrent.ConcurrentCommentedConfig readConfig(Path path) throws IOException, com.electronwill.nightconfig.core.io.ParsingException - Throws:
IOException
com.electronwill.nightconfig.core.io.ParsingException
-
writeConfig
static void writeConfig(Path file, com.electronwill.nightconfig.core.UnmodifiableCommentedConfig config) -
backUpConfig
-
backUpConfig
-