All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ginloader.bukkit-api.1.13.0.source-code.ConfigHelper.kt Maven / Gradle / Ivy

There is a newer version: 3.1.0
Show newest version
package pluginloader.api

import org.bukkit.configuration.ConfigurationSection
import org.bukkit.configuration.MemoryConfiguration

typealias Configuration = ConfigurationSection

fun Configuration.readableString(path: String): String?{
    return (this.getString(path) ?: return null).replace("&", "§")
}

fun config(): Configuration = MemoryConfiguration()

fun Configuration.getFloat(key: String, value: Float = 0.0F) = getDouble(key, value.toDouble()).toFloat()

fun Configuration.string(key: String, default: String = "") = getString(key, default)
fun Configuration.int(key: String, default: Int = 0) = getInt(key, default)
fun Configuration.boolean(key: String, default: Boolean = false) = getBoolean(key, default)
fun Configuration.double(key: String, default: Double = 0.0) = getDouble(key, default)
fun Configuration.float(key: String, default: Float = 0.0F) = getFloat(key, default)
fun Configuration.long(key: String, default: Long = 0L) = getLong(key, default)
fun Configuration.section(key: String): Configuration? = getConfigurationSection(key)

fun Configuration.setString(key: String, value: String): Configuration{
    set(key, value)
    return this
}

fun Configuration.setInt(key: String, value: Int): Configuration{
    set(key, value)
    return this
}

fun Configuration.setBoolean(key: String, value: Boolean): Configuration{
    set(key, value)
    return this
}

fun Configuration.setDouble(key: String, value: Double): Configuration{
    set(key, value)
    return this
}

fun Configuration.setFloat(key: String, value: Float): Configuration{
    set(key, value)
    return this
}

fun Configuration.setLong(key: String, value: Long): Configuration{
    set(key, value)
    return this
}

fun Configuration.setSection(key: String, value: Configuration): Configuration{
    set(key, value)
    return this
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy