69 lines
1.5 KiB
Markdown
69 lines
1.5 KiB
Markdown
## 📄 YML-Manager
|
|
_dveveloped by JernejTDO_
|
|
|
|
A lightweight, high-performance YAML configuration library designed to mimic the intuitive Spigot/Bukkit YamlConfiguration API. This manager provides a simple way to read, write, and update nested YAML files.
|
|
|
|
## 📥 Maven
|
|
Repository
|
|
```xml
|
|
<repositories>
|
|
<repository>
|
|
<id>gitea</id>
|
|
<url>https://git.triler.eu/api/packages/JernejTDO/maven</url>
|
|
</repository>
|
|
</repositories>
|
|
```
|
|
Dependency
|
|
```xml
|
|
<dependency>
|
|
<groupId>net.triler</groupId>
|
|
<artifactId>yml-manager</artifactId>
|
|
<version>0.1</version>
|
|
</dependency>
|
|
```
|
|
|
|
## 🛠 Usage Example
|
|
```java
|
|
File file = new File("config.yml");
|
|
ConfigManager config = new ConfigManager(file);
|
|
|
|
// 1. Load the data from the disk
|
|
config.load();
|
|
|
|
// 2. Read values easily (supports dot-notation)
|
|
String host = config.getString("mysql.host");
|
|
int port = config.getInt("mysql.port");
|
|
|
|
// 3. Working with Lists (e.g., worlds.fly)
|
|
List<String> flyWorlds = config.getStringList("worlds.fly");
|
|
if (!flyWorlds.contains("nether")) {
|
|
flyWorlds.add("nether");
|
|
}
|
|
|
|
// 4. Update or Create new keys
|
|
config.set("mysql.port", 3307);
|
|
config.set("commands.fly.enable", true);
|
|
config.set("worlds.fly", flyWorlds); // Save the updated list
|
|
|
|
// 5. Save the changes back to the file
|
|
config.save();
|
|
```
|
|
```yml
|
|
mysql:
|
|
host: localhost
|
|
port: 3307
|
|
database: database
|
|
user: root
|
|
password: "your-password"
|
|
redis:
|
|
host: localhost
|
|
password: "your-password"
|
|
commands:
|
|
fly:
|
|
enable: true
|
|
worlds:
|
|
fly:
|
|
- world
|
|
- end
|
|
- nether
|
|
``` |