Skip to content

A easy to use Config System for Java

License

Notifications You must be signed in to change notification settings

FoxStudios/Konfig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Konfig

A simple and easy to use configuration system for Java.

Installation

Gradle:

repositories {
    maven { url 'https://maven.foxes4life.net' }
}

dependencies {
    implementation 'net.foxes4life:konfig:1.4.0'
}

Maven:

<repositories>
    <repository>
        <id>foxes4life</id>
        <name>FoxStudios Maven</name>
        <url>https://maven.foxes4life.net</url>
    </repository>
</repositories>

<dependency>
    <groupId>net.foxes4life</groupId>
    <artifactId>konfig</artifactId>
    <version>1.4.0</version>
</dependency>

Usage

Creating a config manager

import net.foxes4life.konfig.Konfig;

public class ExampleConfig extends Konfig<ExampleSettings> {
    public ExampleConfig() {
        super("example");
    }

    public void initializeDefaults() {
        setDefault(ExampleSettings.SETTING, "Hello, world!");
        setDefault(ExampleSettings.ANOTHER_SETTING, 616);
    }
}

// In another file
public enum ExampleSettings {
    SETTING,
    ANOTHER_SETTING
}

Getting and setting values

ExampleConfig config = new ExampleConfig();

String setting = config.get(ExampleSettings.SETTING, String.class);
int anotherSetting = config.get(ExampleSettings.ANOTHER_SETTING, int.class);

config.set(ExampleSettings.SETTING, "Hello, Konfig!");
config.save();
Copyright (C) 2022 FoxStudios