Skip to content

refactor: introduce GlobalConfigWatcher and simplify config lifecycle#6

Merged
devspexx merged 4 commits into
masterfrom
docs/methods-cleanup
Apr 5, 2026
Merged

refactor: introduce GlobalConfigWatcher and simplify config lifecycle#6
devspexx merged 4 commits into
masterfrom
docs/methods-cleanup

Conversation

@devspexx

@devspexx devspexx commented Apr 5, 2026

Copy link
Copy Markdown
Owner

Overview

This PR refactors the configuration system by introducing a single global watcher
(GlobalConfigWatcher) as the source of truth for all configuration state.

The goal is to simplify the architecture, remove duplicated state, and ensure
that configuration snapshots are always up to date.


Key Changes

Architecture

  • Introduced GlobalConfigWatcher to manage all file watching and config state
  • Removed per-config watchers in favor of a single shared watcher
  • Made the watcher the single source of truth for:
    • config instances
    • checksums
    • reload logic

ConfigManager

  • Simplified to API-only layer
  • Removed internal config cache (no duplicated state)
  • Delegates all reads to the watcher

Reload System

  • Atomic replacement of YamlConfig instances
  • SHA-256 checksum-based change detection
  • Debounce mechanism to avoid duplicate reloads
  • Synchronous Bukkit event dispatch (ConfigReloadedEvent)

Event Improvements

  • Updated ConfigReloadedEvent to include:
    • old config
    • new config
    • old checksum
    • new checksum
    • reload time (ms)

Watcher Improvements

  • Ignore untracked files (prevents unnecessary processing)
  • Added unregister() for proper cleanup
  • Improved event handling flow and readability
  • Ensured safe threading (async watcher + sync event dispatch)

Documentation

  • Standardized Javadoc across all classes
  • Improved doclint compatibility
  • Clarified lifecycle, threading, and usage expectations

Result

  • Cleaner and more maintainable architecture
  • No duplicated configuration state
  • Always-consistent config snapshots
  • Improved performance and correctness

@devspexx devspexx merged commit 5a347ea into master Apr 5, 2026
@devspexx devspexx deleted the docs/methods-cleanup branch April 5, 2026 08:53
@devspexx devspexx added the Enhancement An improvement to existing functionality without changing its core behavior. label Apr 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement An improvement to existing functionality without changing its core behavior.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant