JsonConfig

Representation of a json config

Constructors

Link copied to clipboard
constructor(jsonObject: JsonObject)

Loads the config from the given object (but not saved to a file)

constructor(file: File)

Loads the config from the given file

Properties

Link copied to clipboard
var file: File?
Link copied to clipboard
var jsonObject: JsonObject

Functions

Link copied to clipboard
fun add(key: String, value: JsonArray): JsonConfig

Adds a JsonArray to the given key, and if the member already exists, it won't be replaced.

fun add(key: String, element: JsonElement): JsonConfig

Adds an element to the given key, and if the member already exists, it won't be replaced.

fun add(key: String, value: JsonObject): JsonConfig

Adds a JsonObject to the given key, and if the member already exists, it won't be replaced.

fun add(key: String, value: Boolean): JsonConfig

Adds a Boolean to the given key, and if the member already exists, it won't be replaced.

fun add(key: String, value: Int): JsonConfig

Adds an Int to the given key, and if the member already exists, it won't be replaced.

fun add(key: String, value: Number): JsonConfig

Adds a Number to the given key, and if the member already exists, it won't be replaced.

fun add(key: String, value: String): JsonConfig

Adds a String to the given key, and if the member already exists, it won't be replaced.

fun add(key: String, value: JsonConfig): JsonConfig

Adds a JsonConfig to the given key, and if the member already exists, it won't be replaced

Link copied to clipboard
fun decrease(key: String, value: Int = 1): Int

Decreases an Int by the given value or by 1 if no value is specified.

Link copied to clipboard

Destroys the config

Link copied to clipboard
fun get(key: String): JsonElement

Gets an element from the given key

Link copied to clipboard

Gets a Boolean from the given key

Link copied to clipboard
fun getInt(key: String): Int

Gets an Int from the given key

Link copied to clipboard
fun getJsonArray(key: String): JsonArray

Gets a JsonArray from the given key

Link copied to clipboard

Gets a JsonConfig from the given key

Link copied to clipboard

Gets a Number from the given key

Link copied to clipboard
fun getOrCreateJsonArray(key: String): JsonArray

Gets a JsonArray from the given key or creates a new one if it doesn't exist

Link copied to clipboard

Gets a JsonConfig from the given key or creates a new one if it doesn't exist

Link copied to clipboard

Gets a String from the given key

Link copied to clipboard
fun has(key: String): Boolean

Checks if the config has the specified key

Link copied to clipboard
fun increase(key: String, value: Int = 1): Int

Increases an Int by the given value or by 1 if no value is specified.

Link copied to clipboard

Loads the config from the file, and overrides the cache

Link copied to clipboard
fun remove(key: String): JsonElement?

Removes the given key from the JsonObject

Link copied to clipboard

Saves the config to the file

Link copied to clipboard
fun set(key: String, value: JsonArray): JsonConfig

Sets a JsonArray to the given key, and if the member already exists, it will be replaced.

fun set(key: String, element: JsonElement): JsonConfig

Sets a JsonElement to the given key, and if the member already exists, it will be replaced.

fun set(key: String, value: JsonObject): JsonConfig

Sets a JsonObject to the given key, and if the member already exists, it will be replaced.

fun set(key: String, value: Boolean): JsonConfig

Sets a Boolean to the given key, and if the member already exists, it will be replaced.

fun set(key: String, value: Int): JsonConfig

Sets an Int to the given key, and if the member already exists, it will be replaced.

fun set(key: String, value: Number): JsonConfig

Sets a Number to the given key, and if the member already exists, it will be replaced.

fun set(key: String, value: String): JsonConfig

Sets a String to the given key, and if the member already exists, it will be replaced.

fun set(key: String, value: JsonConfig): JsonConfig

Sets a JsonConfig to the given key, and if the member already exists, it will be replaced

Link copied to clipboard
fun toggle(key: String): Boolean

Toggles a Boolean to the given key, and if the member doesn't exist, it will be set to true.