Skip to content
/ Settings Public

A flexible Kotlin library for seamless management and tracking of customizable application settings. Simplify the process of integrating user-configurable options into your projects.

License

Notifications You must be signed in to change notification settings

Lyzev/Settings

Settings

A flexible Kotlin library for seamless management and tracking of customizable application settings. Simplify the process of integrating user-configurable options into your projects.

Discord

GitHub last commit GitHub commit activity
GitHub code size in bytes GitHub contributors

Usage

Import

Replace ${version} with the current version!

Gradle KTS
repositories {
    maven("https://jitpack.io")
}

dependencies {
    implementation("com.github.Lyzev:Settings:${version}")
}
Gradle Groovy
repositories {
    maven { url 'https://jitpack.io' }
}

dependencies {
    implementation 'com.github.Lyzev:Settings:${version}'
}
Maven
<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

<dependencies>
<dependency>
    <groupId>com.github.Lyzev</groupId>
    <artifactId>Settings</artifactId>
    <version>${version}</version>
</dependency>
</dependencies>
Raw Jar
  1. Go to the release page.
  2. Download Settings-${version}.jar.
  3. Add the jar to your classpath.

Example

Example Boolean Setting
import dev.lyzev.api.settings.Setting
import kotlin.reflect.KClass

/**
 * A specific implementation of the [Setting] class for boolean settings.
 *
 * @param container The class of the settings container where this setting belongs.
 * @param name The name of the setting.
 * @param value The initial value of the boolean setting.
 * @param hide A lambda function that determines whether this setting is hidden or not.
 * @param change A lambda function that will be called when the value of the setting changes.
 */
class BooleanSetting(
    container: KClass<*>, name: String, value: Boolean, hide: () -> Boolean = { false }, change: (Boolean) -> Unit = {}
) : Setting<Boolean>(container, name, value, hide, change)

class Test {
    companion object {
        var setting by BooleanSetting(BooleanSetting::class, "test", true) { println("Setting changed to $it") }
    }
}

fun main() {
    // Create an instance of TestSetting with initial values.

    // Print the initial value of the setting.
    println(Test.setting)

    // Change the value of the setting to 'false'.
    Test.setting = false

    // Print the updated value of the setting.
    println(Test.setting)
}

Documentation

You can find the documentation here.

Code Quality Monitoring

You can find the qodana report here.

Bugs and Suggestions

Discord

For assistance with minor concerns, feel free to join our supportive community on the Discord server. Our friendly members and staff are ready to help you.

GitHub

To ensure a prompt and effective resolution of bugs or to share your suggestions, please submit them through the issue tracker of this repository. Kindly utilize the provided templates and make sure to include all relevant details that would help us understand your issue better. Your cooperation is greatly appreciated.