# itzamirreza/ezchestshop architecture

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

- Interactive diagram: https://gitdiagram.com/itzamirreza/ezchestshop
- Repository: https://github.com/itzamirreza/ezchestshop

## Overview

##### Project Type and Purpose
- This is a Java‑based Bukkit/Spigot plugin (EzChestShop) for Minecraft servers.
- It provides chest‑based shop mechanics, command‑driven configuration, GUI menus, event handling, and persistent storage via SQLite or MySQL.
- It also includes version‑specific adapter modules for different CraftBukkit/Spigot server versions (1.16 through 1.20).

##### Key Architectural Elements
a. Plugin Core Module
- Main entry point (EzChestShop.java)
- Command handlers (commands/)
- Event listeners (listeners/)
- Task schedulers (tasks/)
- GUI management (guis/, data/gui/)
- Data layer (Config, LanguageManager, DatabaseManager, PlayerContainer, ShopContainer)
- Database adapters: SQLite (data/sqlite/) and MySQL (data/mysql/)
- Utilities (utils/) such as holograms, pair objects, update checker, webhook sender
- Third‑party library embedded: tr.zeltuv.ezql for SQL abstraction
b. Version Adapter Modules
- Separate Maven submodules for each supported server version (craftbukkit_1_16_R3, …, craftbukkit_1_20_R3)
- Each provides version‑specific implementations of APIs (ChannelHandler, MenuOpener, ImprovedOfflinePlayer, etc.)
c. External Integrations
- Metrics (bstats) via Metrics.java
- Discord webhooks
- Optional plugin integrations (AdvancedRegionMarket, WorldGuard utilities)
d. Deployment
- Parent pom.xml orchestrates multi‑module build
- dist module packages everything for distribution

- Inside it, place a “Plugin Loader” which instantiates EzChestShop.
- EzChestShop to subcomponents:
- Command Module → MainCommands, EcsAdmin, CommandCheckProfits
- Event Module → all listeners (BlockPlaceListener, PlayerTransactionListener, etc.)
- GUI Module → GUI classes (OwnerShopGUI, AdminShopGUI, ContainerGui, etc.)
- Task Scheduler → LoadedChunksTask, UpdateChecker task
- Data Layer → DatabaseManager
– DatabaseManager branches into SQLite adapter and MySQL adapter
– Both use embedded Ezql library
- Utility Layer → ASHologram, WebhookSender, Utils, VersionUtils, etc.
- Metrics & Update Checker → Metrics.java, UpdateChecker
- Off to the side, show “Integration Services”:
- Discord Webhook endpoint
- bStats metrics endpoint
- Optional plugins: WorldGuard, AdvancedRegionMarket

##### Architectural Patterns and Principles
- Modular design via Maven multi-module.
- Adapter pattern for server versions.
- Observer/event‑driven model through Bukkit event listeners.
- Command pattern for slash/console commands.
- DAO‑style abstraction for database access (Ezql).
- Separation of concerns: commands, events, data, UI, integrations.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Top-level server box
    subgraph "Minecraft Server (Bukkit/Spigot API)"
        direction TB
        PL[/"Plugin Loader"/]:::core
        EZ["EzChestShop"]:::core
    end

    PL -->|"instantiates"| EZ

    %% Core plugin components
    subgraph "Core Plugin Components"
        direction TB
        subgraph "Command Module" 
            direction TB
            CMD1["MainCommands"]:::core
            CMD2["EcsAdmin"]:::core
            CMD3["CommandCheckProfits"]:::core
        end

        subgraph "Event Module"
            direction TB
            EVT1["BlockPlaceListener"]:::core
            EVT2["PlayerTransactionListener"]:::core
            EVT3["UpdateChecker"]:::core
        end

        subgraph "Task Scheduler"
            direction TB
            TASK1["LoadedChunksTask"]:::core
        end

        subgraph "GUI Module"
            direction TB
            G1["OwnerShopGUI"]:::core
            G2["AdminShopGUI"]:::core
            G3["NonOwnerShopGUI"]:::core
            G4["ServerShopGUI"]:::core
            G5["CustomMessageManageGUI"]:::core
            G6["GuiEditorGUI"]:::core
            G7["LogsGUI"]:::core
            G8["SettingsGUI"]:::core
        end

        subgraph "GUI Data Models"
            direction TB
            GD1["ContainerGui"]:::core
            GD2["ContainerGuiItem"]:::core
            GD3["GuiData"]:::core
        end

        subgraph "Data Layer"
            direction TB
            D1["Config"]:::core
            D2["LanguageManager"]:::core
            D3["DatabaseManager"]:::core
            D4["PlayerContainer"]:::core
            D5["ShopContainer"]:::core
            D6["ShopCommandManager"]:::core
            subgraph "Database Adapters"
                direction TB
                DA1["SQLite Adapter"]:::core
                DA2["MySQL Adapter"]:::core
                DA1 -->|"uses"| EZQL["Ezql Library"]:::core
                DA2 -->|"uses"| EZQL
            end
        end

        subgraph "Utility Layer"
            direction TB
            U1["ASHologram"]:::core
            U2["WebhookSender"]:::core
            U3["VersionUtils"]:::core
            U4["Utils"]:::core
            U5["Pair"]:::core
            U6["XPEconomy"]:::core
        end

        subgraph "Metrics & Update Checker"
            direction TB
            M1["Metrics"]:::core
            M2["UpdateChecker"]:::core
        end
    end

    %% Connections from EzChestShop
    EZ -->|"commands"| CMD1
    EZ -->|"commands"| CMD2
    EZ -->|"commands"| CMD3
    EZ -->|"registers listeners"| EVT1
    EZ -->|"registers listeners"| EVT2
    EZ -->|"runs task"| TASK1
    EZ -->|"manages GUI"| G1
    EZ -->|"manages GUI"| G2
    EZ -->|"manages GUI"| G3
    EZ -->|"manages GUI"| G4
    EZ -->|"manages GUI"| G5
    EZ -->|"manages GUI"| G6
    EZ -->|"manages GUI"| G7
    EZ -->|"manages GUI"| G8
    EZ -->|"data layer"| D3
    D3 -->|"loads config"| D1
    D3 -->|"manages containers"| D4
    D3 -->|"manages containers"| D5
    EZ -->|"utils"| U1
    EZ -->|"utils"| U2
    EZ -->|"utils"| U3
    EZ -->|"utils"| U4
    EZ -->|"utils"| U5
    EZ -->|"utils"| U6
    EZ -->|"metrics"| M1
    M1 -->|"POST data to"| BSTAT["bStats Endpoint"]:::ext
    M2 -->|"checks update via HTTP"| DISC["Discord Webhook"]:::ext

    %% External integrations
    subgraph "Integration Services"
        direction TB
        BSTAT
        DISC
        WG["WorldGuard (optional)"]:::ext
        ARM["AdvancedRegionMarket"]:::ext
    end

    %% Version adapters
    subgraph "Version Adapter Modules"
        direction TB
        VA16["v1_16_R3 Adapter"]:::version
        VA17["v1_17_R1 Adapter"]:::version
        VA18["v1_18_R2 Adapter"]:::version
        VA19["v1_19_R3 Adapter"]:::version
        VA20["v1_20_R3 Adapter"]:::version
    end

    EZ -->|"runtime adapter"| VA16
    EZ -->|"runtime adapter"| VA17
    EZ -->|"runtime adapter"| VA18
    EZ -->|"runtime adapter"| VA19
    EZ -->|"runtime adapter"| VA20

    %% Build & distribution
    subgraph "Build & Distribution"
        direction TB
        POM["Parent POM"]:::ext
        CPOM["core/pom.xml"]:::ext
        DPOM["dist/pom.xml"]:::ext
    end
    POM --> CPOM
    POM --> DPOM

    %% Click Events
    click EZ "https://github.com/itzamirreza/ezchestshop/blob/main/core/src/main/java/me/deadlight/ezchestshop/EzChestShop.java"
    click CMD1 "https://github.com/itzamirreza/ezchestshop/blob/main/core/src/main/java/me/deadlight/ezchestshop/commands/MainCommands.java"
    click CMD2 "https://github.com/itzamirreza/ezchestshop/blob/main/core/src/main/java/me/deadlight/ezchestshop/commands/EcsAdmin.java"
    click CMD3 "https://github.com/itzamirreza/ezchestshop/blob/main/core/src/main/java/me/deadlight/ezchestshop/commands/CommandCheckProfits.java"
    click EVT1 "https://github.com/itzamirreza/ezchestshop/blob/main/core/src/main/java/me/deadlight/ezchestshop/listeners/BlockPlaceListener.java"
    click EVT2 "https://github.com/itzamirreza/ezchestshop/blob/main/core/src/main/java/me/deadlight/ezchestshop/listeners/PlayerTransactionListener.java"
    click EVT3 "https://github.com/itzamirreza/ezchestshop/blob/main/core/src/main/java/me/deadlight/ezchestshop/listeners/UpdateChecker.java"
    click TASK1 "https://github.com/itzamirreza/ezchestshop/blob/main/core/src/main/java/me/deadlight/ezchestshop/tasks/LoadedChunksTask.java"
    click G1 "https://github.com/itzamirreza/ezchestshop/blob/main/core/src/main/java/me/deadlight/ezchestshop/guis/OwnerShopGUI.java"
    click G2 "https://github.com/itzamirreza/ezchestshop/blob/main/core/src/main/java/me/deadlight/ezchestshop/guis/AdminShopGUI.java"
    click G3 "https://github.com/itzamirreza/ezchestshop/blob/main/core/src/main/java/me/deadlight/ezchestshop/guis/NonOwnerShopGUI.java"
    click G4 "https://github.com/itzamirreza/ezchestshop/blob/main/core/src/main/java/me/deadlight/ezchestshop/guis/ServerShopGUI.java"
    click GD1 "https://github.com/itzamirreza/ezchestshop/blob/main/core/src/main/java/me/deadlight/ezchestshop/data/gui/ContainerGui.java"
    click GD2 "https://github.com/itzamirreza/ezchestshop/blob/main/core/src/main/java/me/deadlight/ezchestshop/data/gui/ContainerGuiItem.java"
    click GD3 "https://github.com/itzamirreza/ezchestshop/blob/main/core/src/main/java/me/deadlight/ezchestshop/data/gui/GuiData.java"
    click D3 "https://github.com/itzamirreza/ezchestshop/blob/main/core/src/main/java/me/deadlight/ezchestshop/data/DatabaseManager.java"
    click DA1 "https://github.com/itzamirreza/ezchestshop/blob/main/core/src/main/java/me/deadlight/ezchestshop/data/sqlite/SQLite.java"
    click DA2 "https://github.com/itzamirreza/ezchestshop/blob/main/core/src/main/java/me/deadlight/ezchestshop/data/mysql/MySQL.java"
    click U2 "https://github.com/itzamirreza/ezchestshop/blob/main/core/src/main/java/me/deadlight/ezchestshop/utils/WebhookSender.java"
    click M1 "https://github.com/itzamirreza/ezchestshop/blob/main/core/src/main/java/me/deadlight/ezchestshop/Metrics.java"
    click ARM "https://github.com/itzamirreza/ezchestshop/blob/main/core/src/main/java/me/deadlight/ezchestshop/integrations/AdvancedRegionMarket.java"
    click VA16 "https://github.com/itzamirreza/ezchestshop/blob/main/craftbukkit_1_16_R3/src/main/java/me/deadlight/ezchestshop/utils/ChannelHandler_v1_16_R3.java"
    click VA17 "https://github.com/itzamirreza/ezchestshop/blob/main/craftbukkit_1_17_R1/src/main/java/me/deadlight/ezchestshop/utils/ChannelHandler_v1_17_R1.java"
    click VA18 "https://github.com/itzamirreza/ezchestshop/blob/main/craftbukkit_1_18_R2/src/main/java/me/deadlight/ezchestshop/utils/ChannelHandler_v1_18_R2.java"
    click VA19 "https://github.com/itzamirreza/ezchestshop/blob/main/craftbukkit_1_19_R3/src/main/java/me/deadlight/ezchestshop/utils/ChannelHandler_v1_19_R3.java"
    click VA20 "https://github.com/itzamirreza/ezchestshop/blob/main/craftbukkit_1_20_R3/src/main/java/me/deadlight/ezchestshop/utils/ChannelHandler_v1_20_R3.java"

    %% Styles
    classDef core fill:#aaf,stroke:#333,stroke-width:1px;
    classDef version fill:#faa,stroke:#333,stroke-width:1px;
    classDef ext fill:#afa,stroke:#333,stroke-width:1px;
```
