Class ConfigFile
Each config begins with a root ConfigCategory which can then have nested
ConfigCategory's, ConfigValue's and ConfigValueList's.
Created by covers1624 on 27/4/22.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionload()Perform loading the config into aConfigCategory.Specifies thePathfor this config file.serializer(ConfigSerializer serializer) Manually set theConfigSerializerto use.
-
Constructor Details
-
ConfigFile
Construct a new Config with the givenrootName.The
rootNameis used when creating translation keys for a given tag. It is recommended that you use your ModID for this, or aResourceLocationlike string.- Parameters:
rootName- The root name for the returned config. Usually your ModID.
-
-
Method Details
-
path
Specifies thePathfor this config file.Usually this will be
Path.of("./config/mymod.cfg")This method will automatically detect the
ConfigSerializerto use based on the File extension of thePath. // TODO document builtin supported formats.- Parameters:
path- The path to the config file.- Returns:
- The same
ConfigFile.
-
serializer
Manually set theConfigSerializerto use.This can be used in the case that the file extension is not sufficient to detect which format is in use, or to support additional formats not currently supported.
- Parameters:
serializer- The serializer.- Returns:
- The same
ConfigFile.
-
load
Perform loading the config into aConfigCategory.This is the root tag in your Config.
This may be empty depending on if the file existed, or there was an erorr loding the file.
- Returns:
- The loaded
ConfigCategory.
-