Class MemoryConfiguration

java.lang.Object
org.bukkit.configuration.MemorySection
org.bukkit.configuration.MemoryConfiguration
All Implemented Interfaces:
Configuration, ConfigurationSection
Direct Known Subclasses:
FileConfiguration

public class MemoryConfiguration
extends MemorySection
implements Configuration
This is a Configuration implementation that does not save or load from any source, and stores all values in memory only. This is useful for temporary Configurations for providing defaults.
  • Field Details

  • Constructor Details

    • MemoryConfiguration

      public MemoryConfiguration()
      Creates an empty MemoryConfiguration with no default values.
    • MemoryConfiguration

      public MemoryConfiguration​(@Nullable @Nullable Configuration defaults)
      Creates an empty MemoryConfiguration using the specified Configuration as a source for all default values.
      Parameters:
      defaults - Default value provider
      Throws:
      java.lang.IllegalArgumentException - Thrown if defaults is null
  • Method Details

    • addDefault

      public void addDefault​(@NotNull @NotNull java.lang.String path, @Nullable @Nullable java.lang.Object value)
      Description copied from interface: ConfigurationSection
      Sets the default value in the root at the given path as provided.

      If no source Configuration was provided as a default collection, then a new MemoryConfiguration will be created to hold the new default value.

      If value is null, the value will be removed from the default Configuration source.

      If the value as returned by ConfigurationSection.getDefaultSection() is null, then this will create a new section at the path, replacing anything that may have existed there previously.

      Specified by:
      addDefault in interface Configuration
      Specified by:
      addDefault in interface ConfigurationSection
      Overrides:
      addDefault in class MemorySection
      Parameters:
      path - Path of the value to set.
      value - Value to set the default to.
    • addDefaults

      public void addDefaults​(@NotNull @NotNull java.util.Map<java.lang.String,​java.lang.Object> defaults)
      Description copied from interface: Configuration
      Sets the default values of the given paths as provided.

      If no source Configuration was provided as a default collection, then a new MemoryConfiguration will be created to hold the new default values.

      Specified by:
      addDefaults in interface Configuration
      Parameters:
      defaults - A map of Path->Values to add to defaults.
    • addDefaults

      public void addDefaults​(@NotNull @NotNull Configuration defaults)
      Description copied from interface: Configuration
      Sets the default values of the given paths as provided.

      If no source Configuration was provided as a default collection, then a new MemoryConfiguration will be created to hold the new default value.

      This method will not hold a reference to the specified Configuration, nor will it automatically update if that Configuration ever changes. If you require this, you should set the default source with Configuration.setDefaults(org.bukkit.configuration.Configuration).

      Specified by:
      addDefaults in interface Configuration
      Parameters:
      defaults - A configuration holding a list of defaults to copy.
    • setDefaults

      public void setDefaults​(@NotNull @NotNull Configuration defaults)
      Description copied from interface: Configuration
      Sets the source of all default values for this Configuration.

      If a previous source was set, or previous default values were defined, then they will not be copied to the new source.

      Specified by:
      setDefaults in interface Configuration
      Parameters:
      defaults - New source of default values for this configuration.
    • getDefaults

      @Nullable public @Nullable Configuration getDefaults()
      Description copied from interface: Configuration
      Gets the source Configuration for this configuration.

      If no configuration source was set, but default values were added, then a MemoryConfiguration will be returned. If no source was set and no defaults were set, then this method will return null.

      Specified by:
      getDefaults in interface Configuration
      Returns:
      Configuration source for default values, or null if none exist.
    • getParent

      @Nullable public @Nullable ConfigurationSection getParent()
      Description copied from interface: ConfigurationSection
      Gets the parent ConfigurationSection that directly contains this ConfigurationSection.

      For any Configuration themselves, this will return null.

      If the section is no longer contained within its parent for any reason, such as being replaced with a different value, this may return null.

      Specified by:
      getParent in interface ConfigurationSection
      Overrides:
      getParent in class MemorySection
      Returns:
      Parent section containing this section.
    • options

      @NotNull public @NotNull MemoryConfigurationOptions options()
      Description copied from interface: Configuration
      Gets the ConfigurationOptions for this Configuration.

      All setters through this method are chainable.

      Specified by:
      options in interface Configuration
      Returns:
      Options for this configuration