# communityradargg/mod_forge_legacy architecture

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

- Interactive diagram: https://gitdiagram.com/communityradargg/mod_forge_legacy
- Repository: https://github.com/communityradargg/mod_forge_legacy

## Overview

##### Project type and purpose
- This is a Minecraft Forge mod (CommunityRadar) for version 1.8.9.
- Its purpose is to let players create and manage “radar lists” of trusted or scammer players in-game via chat commands and to display relevant information on the client side.

##### File structure
- build.gradle, gradlew, settings.gradle: standard Gradle-based Java project.
- src/main/java/io/github/communityradargg/forgemod: contains the mod entrypoint (CommunityRadarMod.java), command handlers, event listeners, and the radar list management subsystem.
- src/main/java/.../radarlistmanager: in-memory model (RadarList, RadarListEntry), manager class, and Gson adapters for JSON serialization.
- src/main/resources/assets/communityradar & mcmod.info: mod metadata and assets.

##### README for additional insights
- Lists the slash commands (`/radar [help]`, `/radar list add …`, `/radar check <player>`, etc.) and their behaviors.

a. Main components
- Forge Mod Loader (FML) and Minecraft Client
- CommunityRadarMod (entrypoint)
- Command Module (RadarCommand)
- Event Module (KeyInputListener, ClientChatReceivedListener, ClientConnectionDisconnectListener, PlayerNameFormatListener)
- RadarListManager (manages RadarList objects in memory)
- Persistence Layer (Gson + adapters: GsonLocalDateTimeAdapter, GsonRadarListPlayerMapAdapter) writing JSON to disk
- Utility Module (Messages, RadarMessage, Utils)
- Resources (assets/communityradar, mcmod.info)
b. Relationships and interactions
1. On client startup, FML loads CommunityRadarMod → registers commands and event listeners on the Forge Event Bus.
2. User types a `/radar` command → Forge routes to RadarCommand → Command Module invokes RadarListManager to create/read/update/delete lists.
3. Event listeners intercept chat messages, key presses, connection/disconnect events → update internal state or push messages via Utility Module.
4. RadarListManager holds lists in memory; when modified (add/remove list or entry), it uses Gson + adapters to serialize to disk (src/main/resources or game config directory).
5. At client disconnect or on demand, Persistence Layer reloads JSON into RadarListManager.
c. Architectural patterns / design principles
- Event-driven architecture via Forge Event Bus
- Command pattern for `/radar` subcommands
- Separation of concerns: commands, events, persistence, utilities
- Use of adapter pattern for custom JSON (Gson adapters)
d. Key technologies
- Java 8
- Minecraft Forge API
- Gradle build system
- Gson for JSON serialization

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client"
        FML["Forge Mod Loader"]:::blue
        MC["Minecraft Client"]:::blue
    end

    subgraph "Mod Core"
        CRM["CommunityRadarMod"]:::modcore
        subgraph "Command Module"
            RC["RadarCommand"]:::modcomp
        end
        subgraph "Event Module"
            CCR["ClientChatReceivedListener"]:::modcomp
            CCD["ClientConnectionDisconnectListener"]:::modcomp
            KI["KeyInputListener"]:::modcomp
            PNF["PlayerNameFormatListener"]:::modcomp
        end
        subgraph "RadarList Manager"
            RLM["RadarListManager"]:::modcore
            RL["RadarList"]:::model
            RLE["RadarListEntry"]:::model
            RLV["RadarListVisibility"]:::model
        end
        subgraph "Utility Module"
            MSG["Messages"]:::util
            RMSG["RadarMessage"]:::util
            UTL["Utils"]:::util
        end
    end

    subgraph "Persistence"
        ADT1["GsonLocalDateTimeAdapter"]:::persistcomp
        ADT2["GsonRadarListPlayerMapAdapter"]:::persistcomp
        JSON["JSON Files"]:::storage
    end

    subgraph "Resources"
        ASSETS["assets/communityradar"]:::resources
        META["mcmod.info"]:::resources
    end

    FML -->|"loads Mod"| CRM
    MC -->|"initializes mod"| CRM

    CRM -->|"registers command"| RC
    CRM -->|"registers listeners"| CCR
    CRM -->|"registers listeners"| CCD
    CRM -->|"registers listeners"| KI
    CRM -->|"registers listeners"| PNF

    MC -->|"chat input"| CCR
    MC -->|"key press"| KI
    MC -->|"disconnect event"| CCD
    MC -->|"format name event"| PNF

    RC -->|"invoke"| RLM
    CCR -->|"invoke"| RLM
    CCD -->|"invoke"| RLM
    KI -->|"invoke"| RLM
    PNF -->|"invoke"| RLM

    RC -->|"uses"| MSG
    RC -->|"sends"| RMSG
    CCR -->|"uses utils"| UTL
    CCD -->|"uses utils"| UTL
    KI -->|"uses utils"| UTL
    PNF -->|"uses utils"| UTL

    RLM -->|"serialize/deserialize"| ADT1
    RLM -->|"serialize/deserialize"| ADT2
    ADT1 -->|"reads/writes"| JSON
    ADT2 -->|"reads/writes"| JSON
    JSON -->|"load on startup"| RLM

    CRM -->|"loads assets"| ASSETS
    CRM -->|"reads metadata"| META

    click CRM "https://github.com/communityradargg/mod_forge_legacy/blob/main/src/main/java/io/github/communityradargg/forgemod/CommunityRadarMod.java"
    click RC "https://github.com/communityradargg/mod_forge_legacy/blob/main/src/main/java/io/github/communityradargg/forgemod/command/RadarCommand.java"
    click CCR "https://github.com/communityradargg/mod_forge_legacy/blob/main/src/main/java/io/github/communityradargg/forgemod/event/ClientChatReceivedListener.java"
    click CCD "https://github.com/communityradargg/mod_forge_legacy/blob/main/src/main/java/io/github/communityradargg/forgemod/event/ClientConnectionDisconnectListener.java"
    click KI "https://github.com/communityradargg/mod_forge_legacy/blob/main/src/main/java/io/github/communityradargg/forgemod/event/KeyInputListener.java"
    click PNF "https://github.com/communityradargg/mod_forge_legacy/blob/main/src/main/java/io/github/communityradargg/forgemod/event/PlayerNameFormatListener.java"
    click RLM "https://github.com/communityradargg/mod_forge_legacy/blob/main/src/main/java/io/github/communityradargg/forgemod/radarlistmanager/RadarListManager.java"
    click RL "https://github.com/communityradargg/mod_forge_legacy/blob/main/src/main/java/io/github/communityradargg/forgemod/radarlistmanager/RadarList.java"
    click RLE "https://github.com/communityradargg/mod_forge_legacy/blob/main/src/main/java/io/github/communityradargg/forgemod/radarlistmanager/RadarListEntry.java"
    click RLV "https://github.com/communityradargg/mod_forge_legacy/blob/main/src/main/java/io/github/communityradargg/forgemod/radarlistmanager/RadarListVisibility.java"
    click ADT1 "https://github.com/communityradargg/mod_forge_legacy/blob/main/src/main/java/io/github/communityradargg/forgemod/radarlistmanager/adapters/GsonLocalDateTimeAdapter.java"
    click ADT2 "https://github.com/communityradargg/mod_forge_legacy/blob/main/src/main/java/io/github/communityradargg/forgemod/radarlistmanager/adapters/GsonRadarListPlayerMapAdapter.java"
    click MSG "https://github.com/communityradargg/mod_forge_legacy/blob/main/src/main/java/io/github/communityradargg/forgemod/util/Messages.java"
    click RMSG "https://github.com/communityradargg/mod_forge_legacy/blob/main/src/main/java/io/github/communityradargg/forgemod/util/RadarMessage.java"
    click UTL "https://github.com/communityradargg/mod_forge_legacy/blob/main/src/main/java/io/github/communityradargg/forgemod/util/Utils.java"
    click ASSETS "https://github.com/communityradargg/mod_forge_legacy/tree/main/src/main/resources/assets/communityradar"
    click META "https://github.com/communityradargg/mod_forge_legacy/blob/main/src/main/resources/mcmod.info"

    classDef blue fill:#D0E7FF,stroke:#0366d6,color:#0366d6
    classDef modcore fill:#DFFFE0,stroke:#28a745,color:#28a745
    classDef modcomp fill:#E0FFE0,stroke:#28a745,color:#28a745
    classDef model fill:#E6F7FF,stroke:#17a2b8,color:#17a2b8
    classDef util fill:#F0F0F0,stroke:#6c757d,color:#6c757d
    classDef persistcomp fill:#FFF4E0,stroke:#fd7e14,color:#fd7e14
    classDef storage fill:#FFEFD5,stroke:#dc3545,color:#dc3545
    classDef resources fill:#F8F9FA,stroke:#6c757d,color:#6c757d
```
