This commit is contained in:
2025-12-17 19:15:13 +00:00
parent 84e7a39dd4
commit da8eb566a8
15 changed files with 61 additions and 35 deletions

View File

@@ -27,17 +27,43 @@ Dependency
File file = new File("config.yml");
ConfigManager config = new ConfigManager(file);
// Load the data from the disk
// 1. Load the data from the disk
config.load();
// Read values easily
// 2. Read values easily (supports dot-notation)
String host = config.getString("mysql.host");
int port = config.getInt("mysql.port");
// Update or Create new keys
// 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
// Save the changes back to the file
// 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
```