Class SimpleConfig

java.lang.Object
me.emafire003.dev.ohmymeteors.config.SimpleConfig

public class SimpleConfig extends Object
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     
    static interface 
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    deletes the config file from the filesystem
    get(String key)
    Deprecated.
     
    boolean
    getOrDefault(String key, boolean def)
    Returns boolean value from config corresponding to the given key, or the default boolean if the key is missing.
    double
    getOrDefault(String key, double def)
    Returns double value from config corresponding to the given key, or the default string if the key is missing or invalid.
    float
    getOrDefault(String key, float def)
    Returns float value from config corresponding to the given key, or the default string if the key is missing or invalid.
    int
    getOrDefault(String key, int def)
    Returns integer value from config corresponding to the given key, or the default integer if the key is missing or invalid.
    Returns string value from config corresponding to the given key, or the default string list if the key is missing.
    Returns string value from config corresponding to the given key, or the default string if the key is missing.
    Returns string value from config corresponding to the given key, or the default string if the key is missing.
    double
    getOrDefaultOrMin(String key, double def, double min)
    Returns double value from config corresponding to the given key, or the default string if the key is missing or invalid.
    boolean
    If any error occurred during loading or reading from the config a 'broken' flag is set, indicating that the config's state is undefined and should be discarded using `delete()`
    of(String filename)
    Creates new config request object, ideally `namespace` should be the name of the mod id of the requesting mod
    void
    parseConfigEntry(String entry, int line)
     
    void
    set(String key, boolean def)
    Saves a new boolean value to the config file
    void
    set(String key, double def)
    Saves a new double value to the config file
    void
    set(String key, int def)
    Saves a new int value to the config file
    void
    set(String key, String def)
    Saves a new String value to the config file
    void
    Used to write to file the updated values stored in the UPDATE MAP
    void
    updateValues(HashMap<com.mojang.datafixers.util.Pair<String,?>, com.mojang.datafixers.util.Pair<String,?>> sub_map)
    Updates from one config version to the other

    Methods inherited from class Object

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

    • of

      public static SimpleConfig.ConfigRequest of(String filename)
      Creates new config request object, ideally `namespace` should be the name of the mod id of the requesting mod
      Parameters:
      filename - - name of the config file
      Returns:
      new config request object
    • updateValues

      public void updateValues(HashMap<com.mojang.datafixers.util.Pair<String,?>, com.mojang.datafixers.util.Pair<String,?>> sub_map) throws IOException
      Updates from one config version to the other
      Throws:
      IOException
    • update

      public void update() throws IOException
      Used to write to file the updated values stored in the UPDATE MAP
      Throws:
      IOException
    • parseConfigEntry

      public void parseConfigEntry(String entry, int line)
    • get

      @Deprecated public String get(String key)
      Deprecated.
      Queries a value from config, returns `null` if the key does not exist.
      Returns:
      value corresponding to the given key
      See Also:
    • getOrDefault

      public List<String> getOrDefault(String key, List<String> def)
      Returns string value from config corresponding to the given key, or the default string if the key is missing.
      Returns:
      value corresponding to the given key, or the default value
    • getOrDefault

      public Map<String,Integer> getOrDefault(String key, Map<String,Integer> def)
      Returns string value from config corresponding to the given key, or the default string if the key is missing.
      Returns:
      value corresponding to the given key, or the default value
    • getOrDefault

      public String getOrDefault(String key, String def)
      Returns string value from config corresponding to the given key, or the default string list if the key is missing.
      Returns:
      value corresponding to the given key, or the default value
    • getConfigCopy

      public HashMap<String,String> getConfigCopy()
    • getOrDefault

      public int getOrDefault(String key, int def)
      Returns integer value from config corresponding to the given key, or the default integer if the key is missing or invalid.
      Returns:
      value corresponding to the given key, or the default value
    • getOrDefault

      public boolean getOrDefault(String key, boolean def)
      Returns boolean value from config corresponding to the given key, or the default boolean if the key is missing.
      Returns:
      value corresponding to the given key, or the default value
    • getOrDefault

      public double getOrDefault(String key, double def)
      Returns double value from config corresponding to the given key, or the default string if the key is missing or invalid.
      Returns:
      value corresponding to the given key, or the default value
    • getOrDefault

      public float getOrDefault(String key, float def)
      Returns float value from config corresponding to the given key, or the default string if the key is missing or invalid.
      Returns:
      value corresponding to the given key, or the default value
    • getOrDefaultOrMin

      public double getOrDefaultOrMin(String key, double def, double min)
      Returns double value from config corresponding to the given key, or the default string if the key is missing or invalid. Returns the minimum value if the one specified is below it
      Returns:
      value corresponding to the given key, or the default value
    • isBroken

      public boolean isBroken()
      If any error occurred during loading or reading from the config a 'broken' flag is set, indicating that the config's state is undefined and should be discarded using `delete()`
      Returns:
      the 'broken' flag of the configuration
    • delete

      public boolean delete() throws IOException
      deletes the config file from the filesystem
      Returns:
      true if the operation was successful
      Throws:
      IOException
    • set

      public void set(String key, boolean def)
      Saves a new boolean value to the config file
    • set

      public void set(String key, String def)
      Saves a new String value to the config file
    • set

      public void set(String key, int def)
      Saves a new int value to the config file
    • set

      public void set(String key, double def)
      Saves a new double value to the config file