We write code, you enjoy it :D
wonders = BoboLabs .add(glowy) .add(stami) .code(); you.enjoy(wonders);
A thread-safe YAML 1.1 configuration library which provides reload and auto-save capabilities. Also very ✨professional✨.
- finely tuned for Minecraft development (Bukkit, Spigot, Paper, Folia, Bungee, Velocity, etc.), but also compatible with any sort of Java project
- flexible and customizable usage in both simple and complex projects (see the examples below)
- thread-safe (especially useful for Folia projects due to its multithreaded nature)
- easily handles multiple configuration files
- both manual and auto save support
- fully reloadable configurations
Vanilla Java | Spigot/Paper | BungeeCord | Velocity | Folia |
---|---|---|---|---|
✔️ | ✔️ | ✔️ | ✔️ | 💡 |
Here are the full Javadocs.
repositories {
maven { url = 'https://repo.bobolabs.net/repository/maven-public/' }
}
dependencies {
implementation 'net.bobolabs.config:config:2.0.0'
}
<repositories>
<repository>
<id>BoboLabs</id>
<url>https://repo.bobolabs.net/maven-public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>net.bobolabs.config</groupId>
<artifactId>config</artifactId>
<version>2.0.0</version>
</dependency>
</dependencies>
Configuration config = ConfigurationLoader
.fromFile(getDataFolder(), "config.yml")
.setDefaultResource("dir/config.yml") // Optional
.autoSave(true) // Optional
.load();
String data = config.getString("my.data");
Describe the configuration files you need by declaring enum fields optionally marked with @Config
.
@Config
accepts several options to meet your needs, find out more here.
public enum Configs implements ConfigurationDescription {
CONFIG,
@Config(path = "configs/gui.yml")
GUI,
@Config(path = "configs/users.yml", autoSave = true)
USER_DATA,
@Config(path = "world.yml", defaultResource = "configs/world.yml", autoSave = true)
WORLD_SETTINGS,
@Config(path = "optional.yml", saveDefaultResource = false)
OPTIONAL_CONFIG
}
Then proceed by creating a ConfigurationManager
which will load the files according to the provided enum.
ConfigurationManager<Configs> configurationManager = new ConfigurationManager<>(getDataFolder(), Configs.class);
The newly created manager can now be used to retrieve single configuration objects which can be used as normal.
Configuration config = configurationManager.load(Configs.GUI);
String guiTitle = config.getString("gui.title");
int guiSize = config.getInt("gui.size");
public final class MyPlugin extends JavaPlugin {
private ConfigurationManager<Configs> configurationManager;
@Override
public void onEnable() {
configurationManager = new ConfigurationManager<>(getDataFolder(), Configs.class);
configurationManager.loadAll();
}
@Override
public void onDisable() {
if (configurationManager != null) {
configurationManager.unloadAll();
configurationManager = null;
}
}
public @NotNull Configuration getConfiguration(@NotNull Configs config) {
return configurationManager.get(config);
}
}