Class SimpleConfig

java.lang.Object
dev.dhyces.compostbag.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.
    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 if the key is missing.
    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

    Methods inherited from class java.lang.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
    • 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 String getOrDefault(String key, 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 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
    • 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