# alexcrea/disenchantment architecture

> Architecture diagram of the GitHub repository alexcrea/disenchantment, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/alexcrea/disenchantment
- Repository: https://github.com/alexcrea/disenchantment

## Overview

##### Main Components
- Plugin Core Module: Represent this as the central “Disenchantment Plugin” container.
- Subcomponents such as:
○ Commands Manager: This covers classes like CommandBuilder, CommandCompleter, CommandRegister, and the various command implementations (e.g., DisenchantEnchantments, DisenchantRepair, etc.).
○ Event Manager: Include custom events (e.g., DisenchantEvent, ShatterEvent, etc.) and their associated listeners (e.g., DisenchantListener, ShatterListener).
○ GUI Framework: List components handling the user interfaces such as GUI, GUIItem, InventoryBuilder, and specific GUI implementations (e.g., DisenchantmentRepairGUI, NavigationGUI).
○ Configuration & Localization: Include the Config, I18n classes, and migration steps. Also denote the config.yml and locale files in resources.
○ NMS (Native Minecraft Server) Compatibility Layer: Represent the NMS base and the version-specific implementations found within the “core” package and the separate version directories.
○ Plugin Integration: Represent the abstraction for supported plugins (like AdvancedEnchantments, EcoEnchants, etc.) that are handled through classes like ISupportedPlugin, SupportedPluginManager, and the concrete implementations in the version directories.

- Version-specific Modules: Because there are directories for v1_18_R1, v1_20_R4, and v1_21_R1, include a “Version Adapter/Bridge” component. This should illustrate:
- Version-specific NMS implementations (like NMS_v1_18_R1.java, NMS_v1_20_R4.java, etc.).
- The corresponding NBT handling classes for each version.
- The version-specific supported plugin wrappers (e.g., AdvancedEnchantments_v1_18_R1.java, etc.)

##### Relationships & Interactions
- For instance, commands issued from the user’s in-game actions go to the Commands Manager. Then these trigger events which are captured by the Event Manager, and from there, call into the GUI Framework or the core business logic.
- The Configuration component should be shown as feeding settings into various modules (commands, GUIs, and even NMS behaviors).
- The Plugin Integration components serve as a bridge between the core plugin functionality and external systems; these should be depicted as interacting with both the Commands/Event layers and the version-specific modules.
- That the NMS Compatibility Layer abstracts away differences between Minecraft versions by interacting with the version-specific implementations.

##### Architectural Patterns & Design Principles
- Modularity: The clear separation between core functionality and version-specific implementations is critical.
- Abstraction: Interfaces (e.g., ICommandExecutor, ICommandCompleter, IConfigMigration, and ISupportedPlugin) are used to decouple implementations from the core logic.
- Extensibility: By isolating integrations with external plugins and Minecraft’s internal (NMS) classes, the design makes it easier to add support for new versions or plugins.

##### Incorporate Relevant Technologies
- Java and Maven are the underlying technologies.
- The use of .yml configuration files for configuration and localization.
- Integration with external libraries (e.g., bStats for metrics and the jars in the version-specific “libs” directory).

- Detail the internal flow by connecting components that interact closely.

## Diagram (Mermaid)

```mermaid
flowchart TD
    SYSTEM["Disenchantment Plugin System"]:::system

    subgraph "Plugin Core Module"
        CoreLabel["Plugin Core Module"]:::corehub
        CFG["Configuration & Localization"]:::config
        CMD["Commands Manager"]:::command
        EVNT["Event Manager"]:::event
        GUI["GUI Framework"]:::gui
        NMSCore["NMS Compatibility Layer"]:::core
        PLUGIN["Plugin Integration"]:::integration
    end

    subgraph "Version Adapter/Bridge"
        subgraph "v1_18_R1"
            NMS18["NMS Implementation"]:::version
            PLUGIN18["Plugin Wrappers"]:::version
            NBT18["NBT Handler"]:::version
        end
        subgraph "v1_20_R4"
            NMS20["NMS Implementation"]:::version
            PLUGIN20["Plugin Wrappers"]:::version
            NBT20["NBT Handler"]:::version
        end
        subgraph "v1_21_R1"
            NMS21["NMS Implementation"]:::version
            PLUGIN21["Plugin Wrappers"]:::version
            NBT21["NBT Handler"]:::version
        end
    end

    %% Top-level flow from system to core components
    SYSTEM -->|"init"| CFG
    SYSTEM -->|"init"| CMD
    SYSTEM -->|"init"| EVNT
    SYSTEM -->|"init"| GUI
    SYSTEM -->|"init"| NMSCore
    SYSTEM -->|"init"| PLUGIN

    %% Internal core interactions
    CFG -->|"configures"| CMD
    CFG -->|"configures"| GUI
    CFG -->|"configures"| NMSCore

    CMD -->|"triggers"| EVNT
    EVNT -->|"updates"| GUI
    PLUGIN -->|"integrates"| CMD
    PLUGIN -->|"integrates"| EVNT

    %% Interactions with version adapters
    NMSCore -->|"delegates"| NMS18
    NMSCore -->|"delegates"| NMS20
    NMSCore -->|"delegates"| NMS21

    PLUGIN -->|"supports"| PLUGIN18
    PLUGIN -->|"supports"| PLUGIN20
    PLUGIN -->|"supports"| PLUGIN21

    %% Click Events for Plugin Core Module
    click CoreLabel "https://github.com/alexcrea/disenchantment/tree/master/core/"
    click CMD "https://github.com/alexcrea/disenchantment/tree/master/core/src/main/java/com/jankominek/disenchantment/commands"
    click EVNT "https://github.com/alexcrea/disenchantment/tree/master/core/src/main/java/com/jankominek/disenchantment/events"
    click GUI "https://github.com/alexcrea/disenchantment/tree/master/core/src/main/java/com/jankominek/disenchantment/guis"
    click CFG "https://github.com/alexcrea/disenchantment/tree/master/core/src/main/java/com/jankominek/disenchantment/config"
    click NMSCore "https://github.com/alexcrea/disenchantment/tree/master/core/src/main/java/com/jankominek/disenchantment/nms"
    click PLUGIN "https://github.com/alexcrea/disenchantment/tree/master/core/src/main/java/com/jankominek/disenchantment/plugins"

    %% Click Events for v1_18_R1
    click NMS18 "https://github.com/alexcrea/disenchantment/tree/master/v1_18_R1/src/main/java/com/jankominek/disenchantment/nms"
    click PLUGIN18 "https://github.com/alexcrea/disenchantment/tree/master/v1_18_R1/src/main/java/plugins"
    click NBT18 "https://github.com/alexcrea/disenchantment/tree/master/v1_18_R1/src/main/java/nbt"

    %% Click Events for v1_20_R4
    click NMS20 "https://github.com/alexcrea/disenchantment/tree/master/v1_20_R4/src/main/java/com/jankominek/disenchantment/nms"
    click PLUGIN20 "https://github.com/alexcrea/disenchantment/tree/master/v1_20_R4/src/main/java/plugins"
    click NBT20 "https://github.com/alexcrea/disenchantment/tree/master/v1_20_R4/src/main/java/nbt"

    %% Click Events for v1_21_R1
    click NMS21 "https://github.com/alexcrea/disenchantment/tree/master/v1_21_R1/src/main/java/com/jankominek/disenchantment/nms"
    click PLUGIN21 "https://github.com/alexcrea/disenchantment/tree/master/v1_21_R1/src/main/java/plugins"
    click NBT21 "https://github.com/alexcrea/disenchantment/tree/master/v1_21_R1/src/main/java/nbt"

    %% Styles
    classDef system fill:#ffcc00,stroke:#333,stroke-width:2px;
    classDef corehub fill:#ccffcc,stroke:#333,stroke-width:1px;
    classDef command fill:#ADD8E6,stroke:#333,stroke-width:1px;
    classDef event fill:#90EE90,stroke:#333,stroke-width:1px;
    classDef gui fill:#FFB6C1,stroke:#333,stroke-width:1px;
    classDef config fill:#FFFF99,stroke:#333,stroke-width:1px;
    classDef integration fill:#DDA0DD,stroke:#333,stroke-width:1px;
    classDef core fill:#87CEFA,stroke:#333,stroke-width:1px;
    classDef version fill:#FFA07A,stroke:#333,stroke-width:1px;
```
