Configuration

How to create a custom configuration

With RocketAPI you can create a custom configuration.

Create a class, extends it to Configuration and create a constructor.

1
public class ExampleConfig extends Configuration {
2
public ExampleConfig(String fileName, JavaPlugin plugin) {
3
super(fileName, plugin);
4
}
5
}
Copied!
Now save the example.yml in the jar
Maven example

Save the configuration in your main class

1
Configuration configuration = new ExampleConfig("example", this);
Copied!
Okay, you've created your example.yml in your plugin folder!

Now you can get a string from the config with

1
// Get the string as an Object
2
configuration.get("example");
3
4
// Get the string as a String
5
configuration.getConfig().getString("example");
Copied!
Remember to create the example field in your config!
Main class
ExampleConfig class
Main.java
579B
Binary
Main
ExampleConfig.java
308B
Binary
ExampleConfig

Last modified 9mo ago