YamlConfiguration is a library for creating and editing YAML files for configurations to be used in Java programs. In addition, it also provides the ability to use in-memory-only Configurations for internal functions, as needed.
It is based off of SpigotMC's Bukkit configuration sub-project, which stems from the original Bukkit Project.
You can obtain a copy of YamlConfiguration via the following methods:
- Download a pre-built copy from the Releases page. The latest version is release 3.0.1.
- Build from source (see below).
- Include it as a dependency in your project (see the Development API section).
YamlConfiguration uses Apache Maven to build and handle dependencies.
- Java Development Kit (JDK) 17 or higher
- Git
- Apache Maven
Run the following commands to build the library .jar
file:
git clone https://github.com/bspfsystems/YamlConfiguration.git
cd YamlConfiguration/
mvn clean install
The .jar
file will be located in the target/
folder.
To add YamlConfiguration as a dependency to your project, use one of the following common methods (you may use others that exist, these are the common ones):
Maven:
Include the following in your pom.xml
file:
<repositories>
<repository>
<id>sonatype-repo</id>
<url>https://oss.sonatype.org/content/repositories/releases/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.bspfsystems</groupId>
<artifactId>yamlconfiguration</artifactId>
<version>3.0.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
Gradle:
Include the following in your build.gradle
file:
repositories {
maven {
url "https://oss.sonatype.org/content/repositories/releases/"
}
}
dependencies {
implementation "org.bspfsystems:yamlconfiguration:3.0.1"
}
These are some basic usages of YamlConfiguration; for a full scope of what the library offers, please see the Javadocs section below.
// Load a file into memory
YamlConfiguration config = new YamlConfiguration();
try {
config.load(new File("config.yml"));
} catch (IOException | InvalidConfigurationException e) {
e.printStackTrace();
}
// Set a few values in the configuration
config.set("random_int", (new Random()).nextInt());
config.set("uuid", UUID.randomUUID().toString());
// Read a value
System.out.println("UUID: " + config.getString("uuid"));
// Save to a file
try {
config.save(new File("newconfig.yml"));
} catch (IOException e) {
e.printStackTrace();
}
The API Javadocs can be found here, kindly hosted by javadoc.io.
Please check out CONTRIBUTING.md for more information.
YamlConfiguration uses the following licenses:
Contributions to the project will remain licensed under the respective license, as defined by the particular license. Copyright/ownership of the contributions shall be governed by the license. The use of an open source license in the hopes that contributions to the project will have better clarity on legal rights of those contributions.
Please Note: This is not legal advice. If you are unsure on what your rights are, please consult a lawyer.