# tiagofar78/prisonescape architecture

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

- Interactive diagram: https://gitdiagram.com/tiagofar78/prisonescape
- Repository: https://github.com/tiagofar78/prisonescape

## Overview

The Prison Escape project is a Minecraft plugin designed to recreate the “Prison Life” minigame within a Minecraft server environment. The plugin is built using Java (with Maven handling project builds and Spotless managing code formatting) and targets systems running JDK 17 or higher. It is structured as a typical Bukkit plugin, integrating game logic (minigame rules, player interactions, and in-game objects) with standard Minecraft server events.

##### Main Components
- Plugin Core: Represented by the main classes (PrisonEscape.java and PEResources.java) that act as initial entry points and integration layers with the Bukkit API.
- Commands Module: Includes all subcommands (ForceStart, ForceStop, Join, Leave, List, LoadMaps, Rejoin, etc.) that handle player inputs and trigger game events. This module is mapped in the src/main/java/net/tiagofar78/prisonescape/commands directory.
- Event Listeners: Found in the listener directory (PlayerListener.java, WorldListener.java) that intercept game events and trigger corresponding actions.
- Game Logic Components: A central part of the system implementing the rules and phases of the minigame. This is distributed in the game and game/phases subdirectories with classes like PEGame, OngoingPhase, WaitingPhase, and FinishedPhase.
- Managers: Configuration, game state, map handling, and language/message managers (ConfigManager, GameManager, MapManager, MessageLanguageManager). These components coordinate state and provide abstraction layers over configuration and runtime management.
- In-Game Objects & Interactions: Comprehensive support for physical game elements like prison buildings (prisonbuilding), doors, placeable items, and interactive items (directories under game/prisonbuilding, items, kits, menus etc.).
- Missions & Kits: Implementations for missions (missions directory) and starter kits for players (kits directory), which add variety to gameplay strategies.
- Plugin Test Server: A separate component (the TestServer folder) that serves as a sandbox environment. It contains its own README, maps, schematics, plugins configurations, and language files meant for testing and development purposes.
- External Configuration & Resources: The src/main/resources directory holds configuration files (config.yml), language files, and map definitions used by the plugin at runtime.

##### Relationships and Interactions
- The Core Bootstrap (PrisonEscape.java) initializes the plugin and registers components – commands, event listeners, and managers.
- Command executions trigger interactions with Managers (GameManager, MapManager) which then modify the game state or initiate actions.
- Event listeners capture game events (player join, world changes) and call corresponding logic in the Game Logic Components.
- The Managers act as an intermediary between the game’s state (including physical objects like prison buildings and dynamic in-game entities) and both user-generated commands and system-triggered events.
- The integration of TestServer resources (e.g., plugin config files, schematics, and maps for TF_PrisonEscape) indicates that there is an isolated environment for testing plugin behavior outside the production server.

##### Architectural Patterns and Principles
- Modularity: The separation between commands, listeners, game logic, items, and managers shows that the design promotes loose coupling.
- Layered Architecture: The plugin’s structure follows layered design where configuration and resource handling is separated from core logic and UI (command/menu) interactions.
- Event-Driven Design: Use of listeners and callbacks align with Minecraft’s event-driven programming model.
- MVC-Like Separation: While not a pure MVC model, there is a clear distinction between input handling (commands/listeners), business logic (game phases, missions, and managers), and data representation (items, in-game objects, configurations).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Plugin Core Subgraph
    subgraph "Plugin Core"
        PC1["PrisonEscape (Core)"]
        PC2["PEResources (Core)"]
    end

    %% Modules outside core
    CM["Commands Module"]
    EL["Event Listeners"]
    MG["Managers (ConfigManager,GameManager,MapManager,MessageLanguageManager)"]

    %% Game Logic Subgraph
    subgraph "Game Logic"
        GL["Game Logic Components"]
        PH["Phases (Ongoing,Waiting,Finished)"]
        GL -->|"triggers_phases"| PH
    end

    %% In-Game Objects Subgraph
    subgraph "In-Game Objects"
        IGB["Prison Building"]
        IGD["Doors"]
        IGP["Placeables"]
        IGR["Regions"]
    end

    %% Missions & Kits Subgraph
    subgraph "Missions & Kits"
        MKM["Missions"]
        MKI["Kits"]
    end

    ER["External Resources (config,maps,languages)"]
    TS["Plugin Test Server"]

    %% Relationships
    PC1 -->|"init_reg_commands"| CM
    PC1 -->|"init_reg_listeners"| EL
    PC1 -->|"init_managers"| MG

    CM -->|"command_call"| GL
    EL -->|"event_trigger"| GL
    MG -->|"manages"| GL
    MG -->|"load_config"| ER

    GL -->|"controls"| IGB
    GL -->|"controls"| IGD
    GL -->|"controls"| IGP
    GL -->|"controls"| IGR

    GL -->|"triggers"| MKM
    GL -->|"triggers"| MKI

    TS -->|"testing_integration"| PC1

    %% Click Events
    click PC1 "https://github.com/tiagofar78/prisonescape/blob/master/src/main/java/net/tiagofar78/prisonescape/PrisonEscape.java"
    click PC2 "https://github.com/tiagofar78/prisonescape/blob/master/src/main/java/net/tiagofar78/prisonescape/PEResources.java"
    click CM "https://github.com/tiagofar78/prisonescape/tree/master/src/main/java/net/tiagofar78/prisonescape/commands"
    click EL "https://github.com/tiagofar78/prisonescape/tree/master/src/main/java/net/tiagofar78/prisonescape/listener"
    click MG "https://github.com/tiagofar78/prisonescape/tree/master/src/main/java/net/tiagofar78/prisonescape/managers"
    click GL "https://github.com/tiagofar78/prisonescape/tree/master/src/main/java/net/tiagofar78/prisonescape/game"
    click PH "https://github.com/tiagofar78/prisonescape/tree/master/src/main/java/net/tiagofar78/prisonescape/game/phases"
    click IGB "https://github.com/tiagofar78/prisonescape/tree/master/src/main/java/net/tiagofar78/prisonescape/game/prisonbuilding"
    click IGD "https://github.com/tiagofar78/prisonescape/tree/master/src/main/java/net/tiagofar78/prisonescape/game/prisonbuilding/doors"
    click IGP "https://github.com/tiagofar78/prisonescape/tree/master/src/main/java/net/tiagofar78/prisonescape/game/prisonbuilding/placeables"
    click IGR "https://github.com/tiagofar78/prisonescape/tree/master/src/main/java/net/tiagofar78/prisonescape/game/prisonbuilding/regions"
    click MKM "https://github.com/tiagofar78/prisonescape/tree/master/src/main/java/net/tiagofar78/prisonescape/missions"
    click MKI "https://github.com/tiagofar78/prisonescape/tree/master/src/main/java/net/tiagofar78/prisonescape/kits"
    click TS "https://github.com/tiagofar78/prisonescape/tree/master/TestServer/plugins/TF_PrisonEscape"
    click ER "https://github.com/tiagofar78/prisonescape/tree/master/src/main/resources"

    %% Styles
    classDef core fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef controller fill:#B0E0E6,stroke:#000,stroke-width:2px;
    classDef manager fill:#FFDAB9,stroke:#000,stroke-width:2px;
    classDef gameLogic fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef ingame fill:#FFFACD,stroke:#000,stroke-width:2px;
    classDef missions fill:#FFC0CB,stroke:#000,stroke-width:2px;
    classDef testServer fill:#D8BFD8,stroke:#000,stroke-width:2px;

    class PC1,PC2 core;
    class CM,EL controller;
    class MG,ER manager;
    class GL,PH gameLogic;
    class IGB,IGD,IGP,IGR ingame;
    class MKM,MKI missions;
    class TS testServer;
```
