# molocko/thesinnerbone architecture

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

- Interactive diagram: https://gitdiagram.com/molocko/thesinnerbone
- Repository: https://github.com/molocko/thesinnerbone

## Overview

##### Project Type and Purpose
- This is a Bukkit/Spigot (Minecraft) server plugin written in Java 17, named “TheSinnerBone.”
- Its purpose is to handle custom in-game events (“грех”) by listening to player actions (kills, respawns), running business logic, and persisting state in YAML files.

##### File-Structure Analysis
- Top-level Gradle build setup (build.gradle, gradlew, settings.gradle) indicates a single Java module.
- src/main/java/io/BM: contains the core code, split into:
- Main.java – plugin entrypoint (extends JavaPlugin)
- TSBCMD.java – command registration/handlers
- onPlayerKill.java, onPlayerRespawn.java – event listeners
- funcs.java, system.java – core business logic
- FileUtils.java – file I/O (config/data persistence)
- src/main/resources:
- plugin.yml – plugin metadata & command/event registration hooks
- config.yml – default configuration

##### Architecture Overview
Main components:
A. Minecraft Server (Spigot/Bukkit API)
B. Plugin Loader (Bukkit’s PluginManager)
C. Plugin Core
1. Main Class
2. Command Handlers (TSBCMD)
3. Event Listeners (onPlayerKill, onPlayerRespawn)
4. Business Logic (funcs, system)
5. FileUtils (YAML config & data store)
D. Storage (config.yml, custom data files)

Interaction flow:
1. Server startup → PluginManager loads Main → reads plugin.yml
2. Main.onEnable(): registers commands (TSBCMD) and events (listeners)
3. Player action triggers Bukkit event → onPlayerKill/onPlayerRespawn invoked
4. Listener calls system/funcs to apply game logic
5. FileUtils updates YAML storage as needed
6. Server returns event results to the client

##### Key Architectural Patterns & Principles
- Event-driven: uses Bukkit’s event bus for decoupled listener invocation.
- Command pattern: TSBCMD handles all user commands centrally.
- Single module plugin: all classes packaged together, loaded as one JAR.
- Separation of concerns: I/O (FileUtils), logic (system/funcs), API integration (Main/listeners).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Server container
    subgraph "Minecraft Server" 
        direction TB
        ServerManager["PluginManager"]:::api
        MainClass["Main (onEnable/onDisable)"]:::api
        TSBCMDNode["TSBCMD"]:::api
        OnKill["onPlayerKill"]:::api
        OnRespawn["onPlayerRespawn"]:::api
        Funcs["funcs"]:::logic
        System["system"]:::logic
        FileUtilsNode["FileUtils"]:::persistence
    end

    %% External entities
    Player["Player"]:::external
    FileSystem["File System\n(config.yml, data.yml)"]:::external
    BuildConfig["Gradle Build\n(build.gradle,\nsettings.gradle,\ngradlew)"]:::external

    %% Startup flow
    ServerStart["Server Startup"]:::external
    ServerStart -->|"loads plugin"| ServerManager
    ServerManager -->|"initialize"| MainClass

    %% Registration
    MainClass -->|"registerCommands/registerListeners"| TSBCMDNode
    MainClass --> TSBCMDNode
    MainClass --> OnKill
    MainClass --> OnRespawn

    %% Command handling flow
    TSBCMDNode -->|"execute command"| System
    System --> Funcs
    Funcs -->|"respond to player"| ServerManager
    ServerManager -->|"send response"| Player

    %% Event-driven flow
    Player -->|triggers kill event| OnKill
    Player -->|triggers respawn event| OnRespawn
    OnKill -.->|calls logic| System
    OnRespawn -.->|calls logic| Funcs
    System --> FileUtilsNode
    Funcs --> FileUtilsNode
    FileUtilsNode -->|"read/write YAML"| FileSystem
    FileSystem -->|storage persists| FileUtilsNode

    %% Build config link
    BuildConfig -.-> MainClass

    %% Click events
    click MainClass "https://github.com/molocko/thesinnerbone/blob/master/src/main/java/io/BM/Main.java"
    click TSBCMDNode "https://github.com/molocko/thesinnerbone/blob/master/src/main/java/io/BM/TSBCMD.java"
    click OnKill "https://github.com/molocko/thesinnerbone/blob/master/src/main/java/io/BM/onPlayerKill.java"
    click OnRespawn "https://github.com/molocko/thesinnerbone/blob/master/src/main/java/io/BM/onPlayerRespawn.java"
    click Funcs "https://github.com/molocko/thesinnerbone/blob/master/src/main/java/io/BM/funcs.java"
    click System "https://github.com/molocko/thesinnerbone/blob/master/src/main/java/io/BM/system.java"
    click FileUtilsNode "https://github.com/molocko/thesinnerbone/blob/master/src/main/java/io/BM/FileUtils.java"
    click FileSystem "https://github.com/molocko/thesinnerbone/blob/master/src/main/resources/config.yml"
    click FileSystem "https://github.com/molocko/thesinnerbone/blob/master/src/main/resources/plugin.yml"

    %% Styles
    classDef api fill:#AEDFF7,stroke:#009,stroke-width:1px
    classDef logic fill:#C6F7B3,stroke:#080,stroke-width:1px
    classDef persistence fill:#F7D6A5,stroke:#D65,stroke-width:1px
    classDef external fill:#E3E4FA,stroke:#666,stroke-width:1px
    classDef server fill:#D3D3D3,stroke:#000,stroke-width:1px
```
