Class ConfigManager

java.lang.Object
dev.cwhead.GravesX.manager.ConfigManager

public final class ConfigManager extends Object
Self-managed configuration system for GravesX.

Does NOT rely on JavaPlugin's built-in config lifecycle (saveDefaultConfig/reloadConfig/saveConfig). It owns extraction, loading, merging, default injection, versioning, backups, and updates.

It still returns Bukkit's FileConfiguration (YamlConfiguration) so the rest of the codebase can keep using getConfig().getX(...).

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    ConfigManager(@NotNull Graves plugin)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull org.bukkit.configuration.file.FileConfiguration
    Returns the currently loaded merged config (lazy loads if needed).
    void
    Extracts jar defaults to disk if missing.
    @NotNull File
     
    @Nullable org.bukkit.configuration.ConfigurationSection
    getConfigSection(String configKey, @NotNull Grave grave)
     
    @Nullable org.bukkit.configuration.ConfigurationSection
    getConfigSection(String configKey, @Nullable List<Grave> graveList)
     
    @Nullable org.bukkit.configuration.ConfigurationSection
    getConfigSection(String configKey, @NotNull org.bukkit.entity.Entity entity)
     
    @Nullable org.bukkit.configuration.ConfigurationSection
    getConfigSection(String configKey, @NotNull org.bukkit.entity.Entity entity, @Nullable List<String> permissionList)
     
    @Nullable org.bukkit.configuration.ConfigurationSection
    getConfigSection(String configKey, @Nullable org.bukkit.entity.EntityType entityType, @Nullable List<String> permissionList)
    Priority order: settings.permission.<perm> settings.entity.<ENTITYTYPE> settings.default.default
    @NotNull List<String>
    getPermissionList(@NotNull org.bukkit.entity.Entity entity)
    Builds a sorted list of permission keys for a given player, matching config sections.
    @NotNull File
     
    void
    init(boolean isDevelopmentBuild)
    Initializes the configuration system: Extract defaults if missing Optionally update configs if outdated / dev build Load merged config into memory
    void
    Reloads configuration from disk (legacy single-file supported; otherwise merges folder mode).
    void
    updateIfNeeded(boolean isDevelopmentBuild)
    Checks disk config-version and updates config files if needed, then reloads.

    Methods inherited from class java.lang.Object

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

    • CURRENT_CONFIG_VERSION

      public static final int CURRENT_CONFIG_VERSION
      See Also:
  • Constructor Details

    • ConfigManager

      public ConfigManager(@NotNull @NotNull Graves plugin)
  • Method Details

    • init

      public void init(boolean isDevelopmentBuild)
      Initializes the configuration system:
      1. Extract defaults if missing
      2. Optionally update configs if outdated / dev build
      3. Load merged config into memory
    • ensureDefaultsExist

      public void ensureDefaultsExist()
      Extracts jar defaults to disk if missing. Uses ResourceUtil copier (not JavaPlugin#saveDefaultConfig).
    • reload

      public void reload()
      Reloads configuration from disk (legacy single-file supported; otherwise merges folder mode).
    • config

      @NotNull public @NotNull org.bukkit.configuration.file.FileConfiguration config()
      Returns the currently loaded merged config (lazy loads if needed).
    • updateIfNeeded

      public void updateIfNeeded(boolean isDevelopmentBuild)
      Checks disk config-version and updates config files if needed, then reloads. This is the former Graves#updateConfig() logic, now owned here.
    • getConfigSection

      @Nullable public @Nullable org.bukkit.configuration.ConfigurationSection getConfigSection(String configKey, @NotNull @NotNull Grave grave)
    • getConfigSection

      @Nullable public @Nullable org.bukkit.configuration.ConfigurationSection getConfigSection(String configKey, @Nullable @Nullable List<Grave> graveList)
    • getConfigSection

      @Nullable public @Nullable org.bukkit.configuration.ConfigurationSection getConfigSection(String configKey, @NotNull @NotNull org.bukkit.entity.Entity entity)
    • getConfigSection

      @Nullable public @Nullable org.bukkit.configuration.ConfigurationSection getConfigSection(String configKey, @NotNull @NotNull org.bukkit.entity.Entity entity, @Nullable @Nullable List<String> permissionList)
    • getConfigSection

      @Nullable public @Nullable org.bukkit.configuration.ConfigurationSection getConfigSection(String configKey, @Nullable @Nullable org.bukkit.entity.EntityType entityType, @Nullable @Nullable List<String> permissionList)
      Priority order:
      1. settings.permission.<perm>
      2. settings.entity.<ENTITYTYPE>
      3. settings.default.default
    • getPermissionList

      @NotNull public @NotNull List<String> getPermissionList(@NotNull @NotNull org.bukkit.entity.Entity entity)
      Builds a sorted list of permission keys for a given player, matching config sections.
    • getConfigFolder

      @NotNull public @NotNull File getConfigFolder()
    • getPluginsFolder

      @NotNull public @NotNull File getPluginsFolder()