Class YamlConfigurationOptions


public final class YamlConfigurationOptions extends FileConfigurationOptions
Represents the various settings for controlling the input and output of a YAML configuration.

Synchronized with the commit on 07-June-2022.

  • Field Details

  • Method Details

    • getConfiguration

      @NotNull public @NotNull YamlConfiguration getConfiguration()
      Gets the configuration that these options controls.
      Overrides:
      getConfiguration in class FileConfigurationOptions
      Returns:
      The configuration that these options controls.
    • setPathSeparator

      @NotNull public @NotNull YamlConfigurationOptions setPathSeparator(char pathSeparator)
      Sets the char that will be used to separate configuration sections.

      This value does not affect how the configuration is stored, only in how you access the data.

      The default value is ..

      Overrides:
      setPathSeparator in class FileConfigurationOptions
      Parameters:
      pathSeparator - The char used to separate configuration sections.
      Returns:
      These options, for chaining.
    • setCopyDefaults

      @NotNull public @NotNull YamlConfigurationOptions setCopyDefaults(boolean copyDefaults)
      Sets if the configuration should copy values from its default configuration directly.

      If this is true, all values in the default configuration will be directly copied, making it impossible to distinguish between values that were set and values that are provided by default. As a result, ConfigurationSection.contains(String) will always return the same value as ConfigurationSection.isSet(String).

      The default value is false.

      Overrides:
      setCopyDefaults in class FileConfigurationOptions
      Parameters:
      copyDefaults - true if the default values should be copied, false otherwise.
      Returns:
      These options, for chaining.
    • setHeader

      @NotNull public @NotNull YamlConfigurationOptions setHeader(@Nullable @Nullable List<String> header)
      Assigns the given header comments to these file configuration options. If the given list is null, an empty list will be assigned.

      For the individual string entries in the list; a null entry represents an empty line, whereas an empty string entry represents an empty header comment line (# and nothing else). Each entry in the list represents 1 line of header comments.

      The given list will not be directly saved; instead, a snapshot will be taken and used to create an unmodifiable copy internally. Further updates to the given list will not result in changes to the inline comments stored in these file configuration options after this method completes.

      Any existing header comments will be replaced, regardless of their value(s) compared to the new header comments.

      Overrides:
      setHeader in class FileConfigurationOptions
      Parameters:
      header - The header comments to assign to these file configuration options.
      Returns:
      These file configuration options, for chaining.
    • setFooter

      @NotNull public @NotNull YamlConfigurationOptions setFooter(@Nullable @Nullable List<String> footer)
      Assigns the given footer comments to these file configuration options. If the given list is null, an empty list will be assigned.

      For the individual string entries in the list; a null entry represents an empty line, whereas an empty string entry represents an empty footer comment line (# and nothing else). Each entry in the list represents 1 line of footer comments.

      The given list will not be directly saved; instead, a snapshot will be taken and used to create an unmodifiable copy internally. Further updates to the given list will not result in changes to the inline comments stored in these file configuration options after this method completes.

      Any existing footer comments will be replaced, regardless of their value(s) compared to the new footer comments.

      Overrides:
      setFooter in class FileConfigurationOptions
      Parameters:
      footer - The footer comments to assign to these file configuration options.
      Returns:
      These file configuration options, for chaining.
    • setParseComments

      @NotNull public @NotNull YamlConfigurationOptions setParseComments(boolean parseComments)
      Sets whether the comments (header, block, inline, and/or footer) in a file configuration should be loaded and saved.

      If this is true, and if a default file configuration is passed to Configuration.setDefaults(Configuration), then upon saving, the default comments will be parsed from the passed default file configuration, instead of the ones provided in here.

      If no default is set on the configuration, or the default is not a file configuration, or that configuration has no comments, then the comments specified in the original configuration will be used.

      The default value is true.

      Overrides:
      setParseComments in class FileConfigurationOptions
      Parameters:
      parseComments - true if the comments are to be parsed, false otherwise.
      Returns:
      This file configuration options, for chaining.
    • getIndent

      public int getIndent()
      Gets the number of spaces used to represent an indent.

      The minimum value this may be is 2, and the maximum is 9.

      The default value is 2.

      Returns:
      The number of spaces used to represent an indent.
    • setIndent

      @NotNull public @NotNull YamlConfigurationOptions setIndent(int indent) throws IllegalArgumentException
      Sets the number of spaces used to represent an indent.

      The minimum value this may be is 2, and the maximum is 9.

      The default value is 2.

      Parameters:
      indent - The number of spaces used to represent an indent.
      Returns:
      These YAML configuration options, for chaining.
      Throws:
      IllegalArgumentException - If the given value is less than 2 or greater than 9.
    • getWidth

      public int getWidth()
      Gets how long a line can be before it gets split.

      The minimum value this may be is 8, and the maximum is 1000.

      The default value is 80.

      Returns:
      The number of characters a line can be before it gets split.
    • setWidth

      @NotNull public @NotNull YamlConfigurationOptions setWidth(int width)
      Sets how long a line can be before it gets split.

      The minimum value this may be is 8, and the maximum is 1000.

      The default value is 80.

      Parameters:
      width - The number of characters a line can be before it gets split.
      Returns:
      These YAML configuration options, for chaining.
      Throws:
      IllegalArgumentException - If the given value is less than 8 or greater than 1000.
    • getMaxAliases

      public int getMaxAliases()
      Gets the maximum number of aliases for collections.

      The minimum value this may be is 10, and the maximum is Integer.MAX_VALUE.

      The default value is 50. It is recommended to keep this value as low as possible for your use case as to prevent a Denial-of-Service known Billion Laughs Attack.

      Returns:
      The maximum number of aliases for collections.
    • setMaxAliases

      @NotNull public @NotNull YamlConfigurationOptions setMaxAliases(int maxAliases) throws IllegalArgumentException
      Sets the maximum number of aliases for collections.

      The minimum value this may be is 10, and the maximum is Integer.MAX_VALUE (please use this wisely).

      A recommended value is 50. It is recommended to keep this value as low as possible for your use case as to prevent a Denial-of-Service known Billion Laughs Attack.

      Parameters:
      maxAliases - The maximum number of aliases for collections.
      Returns:
      These YAML configuration options, for chaining.
      Throws:
      IllegalArgumentException - If the given value is less than 10.
    • getCodePointLimit

      public int getCodePointLimit()
      Gets the maximum number of code points that can be loaded in at one time.

      The minimum is 1kB (1024), and the maximum is Integer.MAX_VALUE (please use this wisely).

      A recommended value is 3 MB (1024 * 1024 * 3).

      Returns:
      The maximum number of code points.
    • setCodePointLimit

      @NotNull public @NotNull YamlConfigurationOptions setCodePointLimit(int codePointLimit) throws IllegalArgumentException
      Sets the maximum number of code points that can be loaded in at one time.

      The minimum is 1kB (1024), and the maximum is Integer.MAX_VALUE (please use this wisely).

      A recommended value is 3 MB (1024 * 1024 * 3).

      Parameters:
      codePointLimit - The maximum number of code points for loading.
      Returns:
      These YAML configuration options, for chaining.
      Throws:
      IllegalArgumentException - If the given value is less than 1kB (1024).