Class CommentConfigManager

java.lang.Object
com.github.pinont.singularitylib.api.manager.CommentConfigManager

public class CommentConfigManager extends Object
A comment-preserving, auto-updating configuration manager (Phase 2 upgrade).

Unlike ConfigManager (plain YamlConfiguration), this class:

  • Preserves inline comments and section headers when saving.
  • Merges missing defaults from a bundled resource WITHOUT destroying user edits.
  • Exposes a mergeDefaults(Map) API and auto-merges on first load.

Comment model: a path -> comment map. When a key is saved the comment is emitted above it. Keys without comments render plain.

  • Constructor Details

    • CommentConfigManager

      public CommentConfigManager(org.bukkit.plugin.Plugin plugin, String fileName)
      Parameters:
      plugin - owning plugin
      fileName - config file name under the plugin data folder
  • Method Details

    • comment

      public CommentConfigManager comment(String path, String comment)
      Attaches a comment to a path (emitted above that key on save).
      Parameters:
      path - the dotted config path
      comment - the comment text (without '#')
      Returns:
      this manager for chaining
    • set

      public void set(String path, Object value)
      Sets a value and saves (preserving comments).
    • get

      public Object get(String path)
    • getBoolean

      public boolean getBoolean(String path, boolean def)
    • getInt

      public int getInt(String path, int def)
    • getString

      public String getString(String path, String def)
    • mergeDefaults

      public boolean mergeDefaults(Map<String,Object> defaults)
      Merges missing defaults from the given map into the config (existing user values win). Returns true if anything was added and a save is advised.
    • save

      public void save()
      Saves to disk with comments preserved.
    • getConfig

      public org.bukkit.configuration.file.YamlConfiguration getConfig()
      Returns:
      the underlying Bukkit configuration (read-only access recommended)