How tiagofar78/prisonescape works
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).