Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Config

Json configuration file reading/writing utility

Hierarchy

  • Config

Index

Constructors

constructor

  • new Config(path: string): Config
  • new Config(file: File): Config

Methods

access

  • access(name: string): Config | JSONArray | boolean | number | string | null

checkAndRestore

  • checkAndRestore(data: string): void
  • checkAndRestore(data: object): void
  • checkAndRestore(data: JSONObject): void
  • Ensures that config has all the properties the data pattern contains, if not, puts default values to match the pattern

    Parameters

    • data: string

      string representation of data pattern

    Returns void

  • Ensures that config has all the properties the data pattern contains, if not, puts default values to match the pattern

    Parameters

    • data: object

      javascript object representing the data patterncheckAndRestore

    Returns void

  • Ensures that config has all the properties the data pattern contains, if not, puts default values to match the pattern

    Parameters

    • data: JSONObject

      org.json.JSONObject instance to be used as data pattern

    Returns void

get

  • get(name: string): Config | JSONArray | boolean | number | string | null
  • Gets property from the config

    Example:

    config.get("generation.ore_copper.max_height");

    Parameters

    • name: string

      option name, supports multi-layer calls, separated by '.'

    Returns Config | JSONArray | boolean | number | string | null

    Config instance with current config as parent if the property is object, org.json.JSONArray instance if the property is an array, raw type if the property is of that raw type, null otherwise

getBool

  • getBool(name: string): boolean
  • Parameters

    • name: string

      option name, supports multi-layer calls, separated by '.'

    Returns boolean

    boolean config value specified in config or false if no value was specified

getNames

  • getNames(): ArrayList<string>
  • Returns ArrayList<string>

    java.util.ArrayList instance containing all the names in the current config file

getNumber

  • getNumber(name: string): Number
  • Parameters

    • name: string

      option name, supports multi-layer calls, separated by '.'

    Returns Number

    number config value specified in config or 0 if no value was specified

getString

  • getString(name: string): string | null
  • Parameters

    • name: string

      option name, supports multi-layer calls, separated by '.'

    Returns string | null

    string config value specified in config or null if no value was specified

getValue

save

  • save(): void

set

  • set(name: string, value: JSONObject | boolean | number | string): boolean
  • Sets config value. Do not use org.json.JSONObject instances to create nested objects, consider using dot-separated names instead

    Parameters

    • name: string

      option name, supports multi-layer calls, separated by '.'

    • value: JSONObject | boolean | number | string

      value, may be org.json.JSONArray instance, org.json.JSONObject instance or raw data type

    Returns boolean

Generated using TypeDoc