Class ReadOnlySettings
-
Constructor Summary
ConstructorsConstructorDescriptionReadOnlySettings
(Settings settings) A wrapper for settings that makes it read-only -
Method Summary
Modifier and TypeMethodDescriptionvoid
Dumps the settings to the console for debugging purposesdouble
Calculates a value for a scaling setting at a given level.double
Calculates a value for a scaling setting at a given level.double
Gets the base value of an attributeboolean
Retrieves a boolean value from the settings.boolean
Retrieves a boolean value from the settings.double
Retrieves a double value from the settings.double
Retrieves a double value from the settings.int
Retrieves an integer value from the settings.int
Retrieves an integer value from the settings.Retrieves a generic attribute.double
Gets the scale value of an attributeRetrieves a string value from the settings.Retrieves a string value from the settings.getStringList
(String key) Retrieves a string list from the settingsboolean
Checks whether the setting is defined.void
save
(studio.magemonkey.codex.mccore.config.parse.DataSection config) Saves settings to a configuration section.
-
Constructor Details
-
ReadOnlySettings
A wrapper for settings that makes it read-only- Parameters:
settings
- settings to wrap
-
-
Method Details
-
getDouble
Retrieves a double value from the settings. If the setting is not set, this will instead return 0.- Parameters:
key
- setting key- Returns:
- double setting value
-
getDouble
Retrieves a double value from the settings. If the setting is not set, this will instead return 0.- Parameters:
key
- setting keydefaultValue
- the default value in case not set- Returns:
- double setting value
-
getInt
Retrieves an integer value from the settings. If the setting is not set, this will instead return 0.- Parameters:
key
- setting key- Returns:
- integer setting value
-
getInt
Retrieves an integer value from the settings. If the setting is not set, this will instead return the default value.- Parameters:
key
- setting keydefaultValue
- the default value in case not set- Returns:
- integer setting value
-
getBool
Retrieves a boolean value from the settings. If the setting is not set, this will instead return false.- Parameters:
key
- setting key- Returns:
- boolean setting value
-
getBool
Retrieves a boolean value from the settings. If the setting is not set, this will instead return false.- Parameters:
key
- setting keydefaultValue
- the default value in case not set- Returns:
- boolean setting value
-
getString
Retrieves a string value from the settings. If the setting is not set, this will instead return null.- Parameters:
key
- setting key- Returns:
- String setting value
-
getString
Retrieves a string value from the settings. If the setting is not set, this will instead return the default value.- Parameters:
key
- setting keydefaultValue
- the default value in case not set- Returns:
- String setting value
-
getStringList
Retrieves a string list from the settings- Parameters:
key
- settings key- Returns:
- string list or empty list if not found
-
getAttr
Calculates a value for a scaling setting at a given level.
If the scaling setting does not exist, this will instead return 0.
- Parameters:
key
- scaling setting namelevel
- level of scaling- Returns:
- scaled setting value
-
getAttr
Calculates a value for a scaling setting at a given level.
If the scaling setting does not exist, this will instead return the provided default value.
- Parameters:
key
- scaling setting namelevel
- level of scalingdefaultValue
- the default value in case not set- Returns:
- scaled setting value
-
getBase
Gets the base value of an attribute
If the attribute is not set, this will return 0.
- Parameters:
key
- attribute name- Returns:
- base value
-
getScale
Gets the scale value of an attribute
If the attribute is not set, this will return 0.
- Parameters:
key
- attribute name- Returns:
- change in value per level
-
getObj
Retrieves a generic attribute.
If the attribute is not set, this will return 0 instead.
- Parameters:
key
- attribute namelevel
- level of scaling- Returns:
- attribute value or 0 if not found
-
has
Checks whether the setting is defined.
A setting is defined when it is set at any point using any of the setter methods or while loading from the configuration.
- Parameters:
key
- name of the setting- Returns:
- true if defined, false otherwise
-
save
public void save(studio.magemonkey.codex.mccore.config.parse.DataSection config) Saves settings to a configuration section.
If the config section is null, this does not do anything.
- Parameters:
config
- configuration section to save to
-
dumpToConsole
public void dumpToConsole()Dumps the settings to the console for debugging purposes
-