Class ConfigManager
java.lang.Object
tech.anonymoushacker1729.cobaltconfig.config.ConfigManager
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionclassToMap(Class<?> configClass) Converts a config class to a map.static @Nullable StringgetComment(Class<?> configClass, String key) Get aConfigEntry.comment()for a given key if present.Class<?>Gets the config class.net.minecraft.network.chat.ComponentGets the config name as aComponent.static PathgetConfigPath(String modId, @Nullable String suffix) Gets the path to the config file.Get the default values of this configuration.static StringGet aConfigEntry.group()for a given key if present.static List<ConfigManager>getManagers(boolean ignoreClientOnly) Get the list of configuration managers.static List<ConfigManager>getManagers(String modId, boolean ignoreClientOnly) Get the list of configuration managers for a specific mod ID.static DoubleGet theConfigEntry.max()for a given key if present.static DoubleGet theConfigEntry.min()for a given key if present.getModId()Gets the mod ID.static booleangetRestartRequired(Class<?> configClass, String key) Get theConfigEntry.restartRequired()for a given key if present.voidinitializeConfig(Class<?> configClass) Initializes the config file by reading the values and setting the static fields.booleanReturns whether the config is client-only.static voidloadFromMap(String configClassName, Map<String, Object> configValues) Loads the config values from a map.voidReloads the config file by reading the values and setting the static fields.static voidReloads all config files.voidWrites the current values of the config class to the config file.
-
Method Details
-
initializeConfig
Initializes the config file by reading the values and setting the static fields.- Parameters:
configClass- the config class
-
reload
Reloads the config file by reading the values and setting the static fields.- Parameters:
configClass- the config class
-
loadFromMap
Loads the config values from a map.- Parameters:
configClassName- the config class nameconfigValues- the config values
-
writeChanges
public void writeChanges()Writes the current values of the config class to the config file. -
reloadAll
public static void reloadAll()Reloads all config files. -
classToMap
Converts a config class to a map.- Parameters:
configClass- the config class- Returns:
- Map
-
getManagers
Get the list of configuration managers. -
getManagers
Get the list of configuration managers for a specific mod ID.- Parameters:
modId- the mod IDignoreClientOnly- whether to ignore client-only configs- Returns:
- List
-
getConfigClass
Gets the config class.- Returns:
- Class
-
getComment
@Nullable @AvailableSince("1.0.0") public static @Nullable String getComment(Class<?> configClass, String key) Get aConfigEntry.comment()for a given key if present.- Parameters:
configClass- the config classkey- the key- Returns:
- the comment or null if not present
-
getGroup
Get aConfigEntry.group()for a given key if present.- Parameters:
configClass- the config classkey- the key- Returns:
- the group if present, otherwise an empty string
-
getMin
Get theConfigEntry.min()for a given key if present.- Parameters:
configClass- the config classkey- the key- Returns:
- the min value. If not specified, it will be
Double.MIN_VALUE
-
getMax
Get theConfigEntry.max()for a given key if present.- Parameters:
configClass- the config classkey- the key- Returns:
- the max value. If not specified, it will be
Double.MAX_VALUE
-
getRestartRequired
Get theConfigEntry.restartRequired()for a given key if present.- Parameters:
configClass- the config classkey- the key- Returns:
- true if a restart is required
-
getDefaultValues
Get the default values of this configuration.- Returns:
- Map
-
getConfigName
@AvailableSince("1.0.0") public net.minecraft.network.chat.Component getConfigName()Gets the config name as aComponent.- Returns:
- Component
-
getModId
Gets the mod ID.- Returns:
- String
-
isClientOnly
@AvailableSince("1.0.0") public boolean isClientOnly()Returns whether the config is client-only.- Returns:
- boolean
-
getConfigPath
Gets the path to the config file.- Parameters:
modId- the mod IDsuffix- the suffix, if any- Returns:
- Path
-