Using the Bungee Configuration System

Apr 20, 2019
Using the Bungee Configuration System
  • BungeeCord Configuration API

    Using the configuration options in the BungeeCord API

    BungeeCord includes a simple configuration API that supports YAML files.

    Loading configuration files(top)

    Unlike Bukkit, where you can use YamlConfiguration.loadConfiguration(), the BungeeCord API requires a configuration provider. The YAML provider is called YamlConfiguration. You can not create an instance of this class yourself; you must request it from the ConfigurationProvider:

    Code (Text):
    Configuration configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(getDataFolder(), "config.yml"));
    Unlike Bukkit, this method will throw IOException if it can't read the file, so you will need to create it first.

    Utilizing the Configuration instance(top)

    Using the instance of Configuration should be straightforward. The most common parts of the API are already implemented, for example getString.

    Saving configuration files(top)

    Once you know how to load the configuration file, this should be rather trivial:

    Code (Text):
    ConfigurationProvider.getProvider(YamlConfiguration.class).save(configuration, new File(getDataFolder(), "config.yml"));

    Bits not provided(top)

    Support for saving a default configuration(top)

    This is easy to work around:

    Code (Text):
                if (!getDataFolder().exists())

                File file = new File(getDataFolder(), "config.yml");

                if (!file.exists()) {
                    try (InputStream in = getResourceAsStream("config.yml")) {
                        Files.copy(in, file.toPath());
                    } catch (IOException e) {

    Support for reloading a configuration(top)

    Simply load the configuration again.
  • Loading...
  • Loading...