# Internal Architecture This document provides a high-level overview of the PixelRTPPool codebase. It is primarily intended for developers and server owners who want to understand how the plugin operates under the hood. ## Manager Hierarchy The plugin is structured around distinct, single-responsibility Managers controlled by a central `RTPManager` facade. ### `ConfigManager` Handles all direct interactions with `config.yml`. It parses strings, instantiates `RTPRegion` immutable data objects, and loads Adventure API configurations. ### `RTPManager` Acts as the central traffic controller. When the WorldGuard `RTPRegionHandler` detects a player entry, it passes the data to the `RTPManager`, which delegates the logic downstream. ### `CountdownManager` Stores and tracks active `BukkitRunnable` teleport tasks using a `ConcurrentHashMap` keyed by `UUID`. Responsible for cancelling tasks safely if conditions change (e.g., the player leaves the region). ### `CooldownManager` Maintains a HashMap of `UUID` -> `Long` (Epoch timestamps). Handles checking if a player is permitted to start a new countdown, and routinely purges expired entries via the `cleanup()` method. ## The Provider Pattern To ensure PixelRTPPool remains infinitely extensible without requiring massive refactors, it utilizes Provider Interfaces. ### `TeleportProvider` Dictates how the teleport logic is actually executed. - `PlayerCommandTeleportProvider`: Forces the player to dispatch the command. - `ConsoleCommandTeleportProvider`: Dispatches the command as console. - *Future*: `BetterRTPProvider` could implement this interface to bypass commands and interact with the BetterRTP Java API directly. ### `CombatProvider` Dictates how combat states are verified. - `NoCombatProvider`: A default implementation that always returns `false` (player is never in combat). - *Future*: A `CombatLogXProvider` could implement this interface to check a player's PvP tag status before allowing the `CountdownManager` to start. ## System Flow (Mermaid) ```mermaid sequenceDiagram participant Player participant WG SessionHandler participant RTPManager participant CountdownManager participant TeleportProvider Player->>WG SessionHandler: Enters RTP Region WG SessionHandler->>RTPManager: trigger pool entry RTPManager->>RTPManager: Check CooldownManager RTPManager->>RTPManager: Check CombatProvider RTPManager->>CountdownManager: Schedule BukkitRunnable loop Every 1 Second CountdownManager->>Player: Send Title, ActionBar, Sound end CountdownManager->>TeleportProvider: Countdown reaches 0 TeleportProvider->>Player: Execute teleport (Player/Console) ``` --- [🏡 Home](Home.md) | [📖 Read Next: Developer Guide](Developer-Guide.md)