# p3sto/townyaddons architecture

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

- Interactive diagram: https://gitdiagram.com/p3sto/townyaddons
- Repository: https://github.com/p3sto/townyaddons

## Overview

##### Project Type and Purpose
- This is a modular Minecraft server plugin meant for Towny servers.
- Its primary goal is to deliver quality‐of‐life improvements through add-ons like Siege Rally, OldCombatSounds, Miner Kit (with a Teams addon on the horizon), and an upcoming Developer API.
- The README emphasizes that the plugin is lightweight, highly configurable, and integrates with external dependencies (e.g., SiegeWar, Apollo-Bukkit, ProtocolLib).

##### Analyzing the File Structure
- The top-level project files (build.gradle, gradlew, etc.) indicate that this is a Gradle-based Java project.
- The main code under src/main/java/io/github/devPesto/townyCore includes several key directories which suggest modularity:
- Main plugin entry point: TownyCore.java
- Commands: Contains command classes (e.g., TownyCoreCommand, SiegeRallyCommand)
- Config: Houses configuration classes (abstract Config, Node, and implementations such as LangConfiguration, PluginConfiguration)
- Expansions: Contains an expansion management system with a manager (TownyExpansionManager) and concrete expansion implementations (e.g., SiegeRallyExpansion, MinerKitExpansion, OldCombatSoundsExpansion)
- Listeners: Provides event listeners (e.g., SiegeRallyListener, MinerKitListener, OldCombatListener) that are likely responsible for hooking into Bukkit events.
- Manager: Contains additional logic (e.g., SiegeRallyManager) which likely orchestrates specific addon functionalities.
- Objects and Util: Hold supporting classes like LunarPlayer and utility classes like ApolloUtil and SchedulerUtil.
- The resources section has configuration files (config.yml, lang.yml) plus the plugin descriptor (plugin.yml), defining the plugin’s metadata and dependencies.

##### Main Components and Their Relationships
- Plugin Core:
- TownyCore.java is the primary class, initializing the plugin and gluing other components.
- Command Module:
- This module (in the commands directory) manages the parsing and execution of commands such as “SiegeRallyCommand” and “TownyCoreCommand”. It interacts with the core and possibly delegates to other service layers.
- Configuration Module:
- Consists of abstract classes (Config, Node) and concrete implementations (LangConfiguration, PluginConfiguration) that manage reading and applying settings from config files.
- These config classes ensure that the plugin behaves as dictated by the configuration files in src/main/resources.
- Expansion System:
- The Expansion Manager (TownyExpansionManager) and the TownyExpansion base class coordinate the lifecycle of different add-ons.
- Each addon (SiegeRally, Miner Kit, OldCombatSounds) is implemented as an expansion (see respective classes). This module also documents external dependencies (e.g., SiegeWar and ProtocolLib) which need to be referenced.
- Listener Module:
- Various listener classes (e.g., SiegerallyListener, MinerKitListener, OldCombatListener) respond to in-game events.
- They are likely registered during plugin initialization and communicate with the command, config, and expansion modules.
- Manager & Utility Classes:
- Additional service layers such as SiegeRallyManager and utility classes (ApolloUtil, SchedulerUtil) encapsulate business logic and external integrations.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Plugin Core"
        TC["Plugin Core (TownyCore)"]:::core
    end

    subgraph "Command Module"
        TCC["TownyCoreCommand"]:::command
        SRC["SiegeRallyCommand"]:::command
    end

    subgraph "Configuration Module"
        ACN["Abstract Config & Node"]:::config
        LC["LangConfiguration"]:::config
        PC["PluginConfiguration"]:::config
    end

    subgraph "Expansion System"
        TE["TownyExpansion"]:::expansion
        TEM["TownyExpansionManager"]:::expansion
        MKE["MinerKitExpansion"]:::expansion
        OCSE["OldCombatSoundsExpansion"]:::expansion
        SRE["SiegeRallyExpansion"]:::expansion
    end

    subgraph "Listener Module"
        SRL["SiegeRallyListener"]:::listener
        MKL["MinerKitListener"]:::listener
        OCL["OldCombatListener"]:::listener
    end

    subgraph "Manager & Utilities"
        SRM["SiegeRallyManager"]:::manager
        AU["ApolloUtil"]:::utility
        SU["SchedulerUtil"]:::utility
    end

    subgraph "External Dependencies"
        SW["SiegeWar"]:::external
        AB["Apollo-Bukkit"]:::external
        PL["ProtocolLib"]:::external
    end

    %% Core interactions
    TC -->|"init"| TCC
    TC -->|"init"| SRC
    TC -->|"loads"| ACN
    TC -->|"manages"| TEM
    TC -->|"registers"| SRL
    TC -->|"invokes"| SRM

    %% Command Module interactions
    TCC -->|"calls"| TEM
    SRC -->|"calls"| SRM

    %% Configuration Module interactions
    ACN -->|"feeds"| LC
    ACN -->|"feeds"| PC

    %% Expansion System interactions
    TEM -->|"controls"| TE
    TEM -->|"controls"| MKE
    TEM -->|"controls"| OCSE
    TEM -->|"controls"| SRE

    %% Listener interactions
    SRL -->|"triggers"| SRM
    MKL -->|"triggers"| SRM
    OCL -->|"triggers"| SRM

    %% Manager & Utility interactions
    SRM -->|"uses"| AU
    AU -->|"integrates"| AB
    SU -->|"schedules"| TC

    %% External Dependencies interactions
    TC -->|"integrates"| PL
    TC -->|"supports"| SW

    %% Class Definitions
    classDef core fill:#F9E79F,stroke:#6E2C00,stroke-width:2px;
    classDef command fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef config fill:#A9DFBF,stroke:#1D8348,stroke-width:2px;
    classDef expansion fill:#FAD7A0,stroke:#AF601A,stroke-width:2px;
    classDef listener fill:#D1F2EB,stroke:#117864,stroke-width:2px;
    classDef manager fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
    classDef utility fill:#F5B7B1,stroke:#943126,stroke-width:2px;
    classDef external fill:#D7DBDD,stroke:#566573,stroke-width:2px;

    %% Click Events
    click TC "https://github.com/p3sto/townyaddons/blob/main/src/main/java/io/github/devPesto/townyCore/TownyCore.java"
    click TCC "https://github.com/p3sto/townyaddons/blob/main/src/main/java/io/github/devPesto/townyCore/commands/TownyCoreCommand.java"
    click SRC "https://github.com/p3sto/townyaddons/blob/main/src/main/java/io/github/devPesto/townyCore/commands/SiegeRallyCommand.java"
    click ACN "https://github.com/p3sto/townyaddons/blob/main/src/main/java/io/github/devPesto/townyCore/config/Config.java"
    click LC "https://github.com/p3sto/townyaddons/blob/main/src/main/java/io/github/devPesto/townyCore/config/impl/LangConfiguration.java"
    click PC "https://github.com/p3sto/townyaddons/blob/main/src/main/java/io/github/devPesto/townyCore/config/impl/PluginConfiguration.java"
    click TE "https://github.com/p3sto/townyaddons/blob/main/src/main/java/io/github/devPesto/townyCore/expansions/TownyExpansion.java"
    click TEM "https://github.com/p3sto/townyaddons/blob/main/src/main/java/io/github/devPesto/townyCore/expansions/TownyExpansionManager.java"
    click MKE "https://github.com/p3sto/townyaddons/blob/main/src/main/java/io/github/devPesto/townyCore/expansions/impl/MinerKitExpansion.java"
    click OCSE "https://github.com/p3sto/townyaddons/blob/main/src/main/java/io/github/devPesto/townyCore/expansions/impl/OldCombatSoundsExpansion.java"
    click SRE "https://github.com/p3sto/townyaddons/blob/main/src/main/java/io/github/devPesto/townyCore/expansions/impl/SiegeRallyExpansion.java"
    click SRL "https://github.com/p3sto/townyaddons/blob/main/src/main/java/io/github/devPesto/townyCore/listener/SiegeRallyListener.java"
    click MKL "https://github.com/p3sto/townyaddons/blob/main/src/main/java/io/github/devPesto/townyCore/listener/MinerKitListener.java"
    click OCL "https://github.com/p3sto/townyaddons/blob/main/src/main/java/io/github/devPesto/townyCore/listener/OldCombatListener.java"
    click SRM "https://github.com/p3sto/townyaddons/blob/main/src/main/java/io/github/devPesto/townyCore/manager/SiegeRallyManager.java"
    click AU "https://github.com/p3sto/townyaddons/blob/main/src/main/java/io/github/devPesto/townyCore/util/ApolloUtil.java"
    click SU "https://github.com/p3sto/townyaddons/blob/main/src/main/java/io/github/devPesto/townyCore/util/SchedulerUtil.java"
```
