bukkit Configuration Files Plugin Config.yml

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

You can have a config.yml file that loads directly from your jar file. It must be added to your project's folder, the same way as the plugin.yml file is.

In this file you have the default values for your configuration.

Example config:

# This is an YML comment
adminName: "Kerooker"
moderators: ["Romario", "PelĂ©", "CafĂș"]

The example config file must be added to the project folder.

To load the default configuration file to your plugin's folder, the following code must be added to your onEnable():

saveDefaultConfig();

This will make your config.yml file from the project to be your plugin's configuration file, and will add it to your plugin's folder.

From there, you can access your config file from anywhere, by using your plugin instance:

JavaPlugin plugin; // Your plugin instance
FileConfiguration config = plugin.getConfig();  //Accessing the config file

From there, we can access anything that was set on the plugin's config.

Note: The default config file may have it's values changed, if the user wants to edit the config.yml file generated to the folder.

String adminName = config.getString("adminName");
List<String> moderators =  config.getStringList("moderators");


Got any bukkit Question?