All Implemented Interfaces:
Configuration, ConfigurationSection

public final class YamlConfiguration extends FileConfiguration
Represents an implementation of configuration which saves all files in valid YAML format. Please note that this implementation is not synchronized.

Synchronized with the commit on 16-April-2023.

  • Constructor Details

    • YamlConfiguration

      public YamlConfiguration()
      Constructs an empty YAML configuration with no default values.
      See Also:
    • YamlConfiguration

      public YamlConfiguration(@Nullable @Nullable Configuration defs)
      Constructs an empty YAML configuration using the given configuration as a source for all default values.
      Parameters:
      defs - The default value provider configuration
      See Also:
  • Method Details

    • saveToString

      @NotNull public @NotNull String saveToString()
      Converts this file configuration to a string.
      Specified by:
      saveToString in class FileConfiguration
      Returns:
      A string representing this file configuration.
    • loadFromString

      public void loadFromString(@NotNull @NotNull String data) throws InvalidConfigurationException
      Loads this file configuration from the given string.

      All values contained in-memory in this file configuration will be removed, leaving only the file configuration options as well as any defaults. The new values will be loaded into memory from the given string.

      Specified by:
      loadFromString in class FileConfiguration
      Parameters:
      data - The string representation of the file configuration data to load.
      Throws:
      InvalidConfigurationException - If the given string cannot be parsed as a file configuration.
    • getOptions

      @NotNull public @NotNull YamlConfigurationOptions getOptions()
      Gets the options for this configuration.

      All setters through this method are chainable.

      Specified by:
      getOptions in interface Configuration
      Overrides:
      getOptions in class FileConfiguration
      Returns:
      The options for this configuration.
    • loadConfiguration

      @NotNull public static @NotNull YamlConfiguration loadConfiguration(@NotNull @NotNull File file)
      Creates a new YAML configuration, loading from the given file.

      Any errors loading the YAML configuration will be logged and then otherwise ignored. If the given input is not a valid YAML configuration, an empty YAML configuration will be returned.

      This will only load up to the default number of aliases (YamlConfigurationOptions.getMaxAliases()) to prevent a Billion Laughs Attack.

      The encoding used may follow the system dependent default.

      Parameters:
      file - The file to load.
      Returns:
      The loaded YAML configuration.
    • loadConfiguration

      @NotNull public static @NotNull YamlConfiguration loadConfiguration(@NotNull @NotNull Reader reader)
      Creates a new YAML configuration, loading from the given reader.

      Any errors loading the YAML configuration will be logged and then otherwise ignored. If the given input is not a valid YAML configuration, an empty YAML configuration will be returned.

      This will only load up to the default number of aliases (YamlConfigurationOptions.getMaxAliases()) to prevent a Billion Laughs Attack.

      The encoding used may follow the system dependent default.

      Parameters:
      reader - The reader to load.
      Returns:
      The loaded YAML configuration.