Class ConfigSection<T extends IConfigSectionResult>

java.lang.Object
nl.pim16aap2.animatedarchitecture.core.config.ConfigSection<T>
Direct Known Subclasses:
AnimationsSection, CachingSection, GeneralSection, LimitsSection, LocaleSection, LoggingSection, ProtectionHooksSection, RedstoneSection, StructuresSection

public abstract class ConfigSection<T extends IConfigSectionResult> extends Object
Represents a section in the configuration.

This interface defines the contract for configuration sections, which are used to define specific parts of the configuration with their own initial transform actions.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    applyResults(org.spongepowered.configurate.ConfigurationNode root, boolean silent)
    Applies the results of this section.
    abstract org.spongepowered.configurate.CommentedConfigurationNode
    Builds the initial limits node for this configuration section.
    protected String
    Formats a default collection of values as a string.
    protected abstract T
    getResult(org.spongepowered.configurate.ConfigurationNode sectionNode, boolean silent)
    Gets the result of this configuration section.
    protected abstract @Nullable Consumer<T>
    Gets the consumer that will handle the result of this configuration section.
    org.spongepowered.configurate.CommentedConfigurationNode
    getSection(org.spongepowered.configurate.CommentedConfigurationNode root)
    Gets the subsection for this configuration section.
    abstract String
    Returns the title of the configuration section.
    void
    populateDynamicData(org.spongepowered.configurate.CommentedConfigurationNode root)
    Populates the dynamic data for this configuration section.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ConfigSection

      public ConfigSection()
  • Method Details

    • buildInitialLimitsNode

      public abstract org.spongepowered.configurate.CommentedConfigurationNode buildInitialLimitsNode() throws org.spongepowered.configurate.serialize.SerializationException
      Builds the initial limits node for this configuration section.

      This method is responsible for creating the initial configuration node for this section, including any default values and comments.

      Returns:
      the initial limits node for this section
      Throws:
      org.spongepowered.configurate.serialize.SerializationException - if an error occurs during serialization
    • getResult

      protected abstract T getResult(org.spongepowered.configurate.ConfigurationNode sectionNode, boolean silent) throws org.spongepowered.configurate.serialize.SerializationException
      Gets the result of this configuration section.
      Parameters:
      sectionNode - The configuration node for this section.
      silent - When true, the method will not log any informational/status messages when parsing the results.
      Returns:
      the result of this configuration section
      Throws:
      org.spongepowered.configurate.serialize.SerializationException - If an error occurs during serialization.
    • getResultConsumer

      protected abstract @Nullable Consumer<T> getResultConsumer()
      Gets the consumer that will handle the result of this configuration section.
      Returns:
      the consumer that will handle the result, or null if no consumer is defined.
    • formatDefaultCollection

      protected String formatDefaultCollection(Collection<String> values)
      Formats a default collection of values as a string.
      Parameters:
      values - The values to format as a collection.
      Returns:
      A string representation of the collection, or "[]" if no values are provided.
    • applyResults

      public final void applyResults(org.spongepowered.configurate.ConfigurationNode root, boolean silent) throws org.spongepowered.configurate.serialize.SerializationException
      Applies the results of this section.
      Parameters:
      root - The root configuration node to read the data from.
      silent - When true, the method will not log any informational/status messages when parsing the results.
      Throws:
      org.spongepowered.configurate.serialize.SerializationException
    • getSection

      public org.spongepowered.configurate.CommentedConfigurationNode getSection(org.spongepowered.configurate.CommentedConfigurationNode root)
      Gets the subsection for this configuration section.
      Parameters:
      root - The root configuration node to get the subsection from.
      Returns:
      the subsection node for this configuration section
      Throws:
      IllegalStateException - if the section does not exist.
    • populateDynamicData

      public void populateDynamicData(org.spongepowered.configurate.CommentedConfigurationNode root)
      Populates the dynamic data for this configuration section.

      This method will not overwrite existing data in the node; it will only add new data if any is missing.

      Parameters:
      root - The root configuration node to populate with dynamic data.
    • getSectionTitle

      public abstract String getSectionTitle()
      Returns the title of the configuration section.
      Returns:
      the title of the section