# kruase76/lingering-potion-crafting architecture

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

- Interactive diagram: https://gitdiagram.com/kruase76/lingering-potion-crafting
- Repository: https://github.com/kruase76/lingering-potion-crafting

## Overview

##### Main Components Identification
- Main Plugin Class: At the heart is the main plugin bootstrap (LingeringPotionCrafting.kt), responsible for initializing the plugin within the Spigot framework.
- Command Management:
– LPCCommands.kt is the central handler for commands.
– The commands/ submodule (help.kt and reload.kt) implements specific command behaviors.
- Event Handling: LPCEvents.kt manages the in-game events triggered by Minecraft (e.g., interactions related to potion effects).
- Configuration/Recipe Management:
– LPCConfig.kt and LPCRecipeConfig.kt handle the plugin’s settings and recipe definitions.
- Domain Logic: The logic/ classes (AreaEffectCloudExt.kt, ItemExt.kt) extend or integrate Minecraft API features to support custom effects.
- Utility Functions: Located under util/ (e.g., CommandSenderExt.kt, LoggerExt.kt, PersistentDataContainerExt.kt), these provide helper methods for logging, data persistence, and command sender adaptation.
- Resource Files: The configuration files (config.yml, plugin.yml, recipes.yml) loaded at runtime to control plugin behavior and register metadata with the host server.

##### Inter-component Relationships & Data Flow
- The Main Plugin Class initializes the environment by reading configuration (from config.yml, recipes.yml) and loading the plugin data from plugin.yml.
- It subsequently registers commands (via LPCCommands.kt) and event listeners (via LPCEvents.kt) with the Spigot/Bukkit API.
- When a command like “/lpc reload” is invoked, control is passed to its corresponding command implementation (reload.kt), which then dispatches calls to configuration and utility classes to update settings.
- Event listeners intercept in-game events and delegate behavior to logic classes (under logic/) for custom potion crafting effects.
- Utility classes serve across multiple components to support logging, data handling, and command enhancements.

##### Architectural Patterns & Design Principles
- Modularity: The clear partitioning into commands, events, logic, and utilities reflects a modular design, where each module encapsulates specific functionality.
- Separation of Concerns: The separation between configuration, command handling, game logic, and utility operations promotes maintainability.
- Extensibility: With distinct modules for recipe configuration and logic extensions, the system is designed to be easily extended by adding new commands or modifying game behavior.
- Integration with Spigot/Bukkit API: The architecture heavily relies on the event-driven, plugin-based framework provided by Spigot.

##### Technologies & Frameworks
- Kotlin (as the core programming language)
- Maven (pom.xml indicates usage for build management)
- Spigot/Bukkit API (for Minecraft server integration)

## Diagram (Mermaid)

```mermaid
graph TD
    %% Diagram Background Color: #00d2c1

    %% Plugin Bootstrap
    A["Main Plugin"]:::main

    %% Command Management
    subgraph "Command Management"
        B["Command Handler"]:::command
        subgraph "Commands"
            B1["Help Command"]:::command
            B2["Reload Command"]:::command
        end
    end

    %% Event Handling
    subgraph "Event Handling"
        C["Event Listener"]:::events
    end

    %% Configuration & Recipe Management
    subgraph "Configuration & Recipe Management"
        D1["Configuration Handler"]:::config
        D2["Recipe Configuration"]:::config
        subgraph "Resource Files"
            R1["Config File"]:::resource
            R2["Plugin Metadata"]:::resource
            R3["Recipes File"]:::resource
        end
    end

    %% Domain Logic
    subgraph "Domain Logic"
        E1["AreaEffectCloudExt"]:::logic
        E2["ItemExt"]:::logic
    end

    %% Utility Functions
    subgraph "Utility Functions"
        F1["CommandSenderExt"]:::util
        F2["LoggerExt"]:::util
        F3["PersistentDataExt"]:::util
    end

    %% Connections
    A -->|"registers"| B
    A -->|"registers"| C
    A -->|"loads"| D1
    A -->|"loads"| D2
    B -->|"implements"| B1
    B -->|"implements"| B2
    B2 -->|"updates"| D1
    D1 -->|"loads"| R1
    D1 -->|"loads"| R2
    D1 -->|"loads"| R3
    C -->|"delegates to"| E1
    C -->|"delegates to"| E2
    E1 -->|"uses"| F1
    E2 -->|"uses"| F1
    D1 -->|"logs via"| F2
    D1 -->|"saves via"| F3

    %% Click Events
    click A "https://github.com/kruase76/lingering-potion-crafting/blob/main/src/main/kotlin/me/kruase/lingering_potion_crafting/LingeringPotionCrafting.kt"
    click B "https://github.com/kruase76/lingering-potion-crafting/blob/main/src/main/kotlin/me/kruase/lingering_potion_crafting/LPCCommands.kt"
    click B1 "https://github.com/kruase76/lingering-potion-crafting/blob/main/src/main/kotlin/me/kruase/lingering_potion_crafting/commands/help.kt"
    click B2 "https://github.com/kruase76/lingering-potion-crafting/blob/main/src/main/kotlin/me/kruase/lingering_potion_crafting/commands/reload.kt"
    click C "https://github.com/kruase76/lingering-potion-crafting/blob/main/src/main/kotlin/me/kruase/lingering_potion_crafting/LPCEvents.kt"
    click D1 "https://github.com/kruase76/lingering-potion-crafting/blob/main/src/main/kotlin/me/kruase/lingering_potion_crafting/LPCConfig.kt"
    click D2 "https://github.com/kruase76/lingering-potion-crafting/blob/main/src/main/kotlin/me/kruase/lingering_potion_crafting/LPCRecipeConfig.kt"
    click R1 "https://github.com/kruase76/lingering-potion-crafting/blob/main/src/main/resources/config.yml"
    click R2 "https://github.com/kruase76/lingering-potion-crafting/blob/main/src/main/resources/plugin.yml"
    click R3 "https://github.com/kruase76/lingering-potion-crafting/blob/main/src/main/resources/recipes.yml"
    click E1 "https://github.com/kruase76/lingering-potion-crafting/blob/main/src/main/kotlin/me/kruase/lingering_potion_crafting/logic/AreaEffectCloudExt.kt"
    click E2 "https://github.com/kruase76/lingering-potion-crafting/blob/main/src/main/kotlin/me/kruase/lingering_potion_crafting/logic/ItemExt.kt"
    click F1 "https://github.com/kruase76/lingering-potion-crafting/blob/main/src/main/kotlin/me/kruase/lingering_potion_crafting/util/CommandSenderExt.kt"
    click F2 "https://github.com/kruase76/lingering-potion-crafting/blob/main/src/main/kotlin/me/kruase/lingering_potion_crafting/util/LoggerExt.kt"
    click F3 "https://github.com/kruase76/lingering-potion-crafting/blob/main/src/main/kotlin/me/kruase/lingering_potion_crafting/util/PersistentDataContainerExt.kt"

    %% Styles
    classDef main fill:#ffeaa7,stroke:#333,stroke-width:2px;
    classDef command fill:#74b9ff,stroke:#333,stroke-width:2px;
    classDef events fill:#55efc4,stroke:#333,stroke-width:2px;
    classDef config fill:#fab1a0,stroke:#333,stroke-width:2px;
    classDef logic fill:#fd79a8,stroke:#333,stroke-width:2px;
    classDef util fill:#a29bfe,stroke:#333,stroke-width:2px;
    classDef resource fill:#81ecec,stroke:#333,stroke-width:2px;
```
