Class ReadOnlySettings

java.lang.Object
studio.magemonkey.fabled.api.ReadOnlySettings

public class ReadOnlySettings extends Object
A wrapper for the API settings that makes it read-only
  • Constructor Summary

    Constructors
    Constructor
    Description
    A wrapper for settings that makes it read-only
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Dumps the settings to the console for debugging purposes
    double
    getAttr(String key, int level)
    Calculates a value for a scaling setting at a given level.
    double
    getAttr(String key, int level, double defaultValue)
    Calculates a value for a scaling setting at a given level.
    double
    Gets the base value of an attribute
    boolean
    Retrieves a boolean value from the settings.
    boolean
    getBool(String key, boolean defaultValue)
    Retrieves a boolean value from the settings.
    double
    Retrieves a double value from the settings.
    double
    getDouble(String key, double defaultValue)
    Retrieves a double value from the settings.
    int
    Retrieves an integer value from the settings.
    int
    getInt(String key, int defaultValue)
    Retrieves an integer value from the settings.
    getObj(String key, int level)
    Retrieves a generic attribute.
    double
    Gets the scale value of an attribute
    Retrieves a string value from the settings.
    getString(String key, String defaultValue)
    Retrieves a string value from the settings.
    Retrieves a string list from the settings
    boolean
    has(String key)
    Checks whether the setting is defined.
    void
    save(studio.magemonkey.codex.mccore.config.parse.DataSection config)
    Saves settings to a configuration section.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ReadOnlySettings

      public ReadOnlySettings(Settings settings)
      A wrapper for settings that makes it read-only
      Parameters:
      settings - settings to wrap
  • Method Details

    • getDouble

      public double getDouble(String key)
      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

      public double getDouble(String key, double defaultValue)
      Retrieves a double value from the settings. If the setting is not set, this will instead return 0.
      Parameters:
      key - setting key
      defaultValue - the default value in case not set
      Returns:
      double setting value
    • getInt

      public int getInt(String key)
      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

      public int getInt(String key, int defaultValue)
      Retrieves an integer value from the settings. If the setting is not set, this will instead return the default value.
      Parameters:
      key - setting key
      defaultValue - the default value in case not set
      Returns:
      integer setting value
    • getBool

      public boolean getBool(String key)
      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

      public boolean getBool(String key, boolean defaultValue)
      Retrieves a boolean value from the settings. If the setting is not set, this will instead return false.
      Parameters:
      key - setting key
      defaultValue - the default value in case not set
      Returns:
      boolean setting value
    • getString

      public String getString(String key)
      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

      public String getString(String key, String defaultValue)
      Retrieves a string value from the settings. If the setting is not set, this will instead return the default value.
      Parameters:
      key - setting key
      defaultValue - the default value in case not set
      Returns:
      String setting value
    • getStringList

      public List<String> getStringList(String key)
      Retrieves a string list from the settings
      Parameters:
      key - settings key
      Returns:
      string list or empty list if not found
    • getAttr

      public double getAttr(String key, int level)

      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 name
      level - level of scaling
      Returns:
      scaled setting value
    • getAttr

      public double getAttr(String key, int level, double defaultValue)

      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 name
      level - level of scaling
      defaultValue - the default value in case not set
      Returns:
      scaled setting value
    • getBase

      public double getBase(String key)

      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

      public double getScale(String key)

      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

      public Object getObj(String key, int level)

      Retrieves a generic attribute.

      If the attribute is not set, this will return 0 instead.

      Parameters:
      key - attribute name
      level - level of scaling
      Returns:
      attribute value or 0 if not found
    • has

      public boolean has(String key)

      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