How alexandrebarde/pluginopenmc works
Project Type and Purpose
• This is a monolithic Java plugin (“Plugin OpenMC”) for a Minecraft server (Spigot/Paper).
• It follows the Bukkit API event-driven model: on startup it registers commands and listeners, handles player interactions, and persists data via database or YAML files.
File Structure Analysis
• Top-level build files: build.gradle, settings.gradle, gradle wrapper → standard Gradle-based Java project.
• src/main/java/fr/communaywen/core/AywenCraftPlugin.java → plugin’s main class.
• Packages under core:
• commands/… → individual command handlers (e.g., FeedCommand, MoneyCommand)
• listeners/… → event listeners (e.g., ChatListener, ExplosionListener)
• economy/, friends/, teams/, tpa/ → domain-specific managers and data classes
• utils/… → low-level helpers (DatabaseManager, DiscordWebhook, GitHubAPI, etc.)
• src/main/resources: plugin.yml (plugin metadata), config.yml + quizzes.yml + other YAMLs for runtime config.
README Insights
• Confirms collaborative plugin development for a live “dev.openmc.fr” server.
Main Components
a. Minecraft Server (Spigot/Paper)
b. Plugin Core
• Bootstrap (AywenCraftPlugin)
• Command Registry (all commands in commands/)
• Event Dispatcher (all listeners in listeners/)
c. Domain Managers
• EconomyManager & EconomyData
• FriendsManager & FriendsRequest
• QuizManager
• TeamManager & Team data
• TPAQueue
• ScoreboardManagers
d. Persistence & Config
• DatabaseManager → relational or embedded database (via DatabaseConnection)
• YAML storages (config.yml, quizzes.yml, rules.yml, …)
e. Utility/Integration Layer
• DiscordWebhook
• GitHubAPI, DraftAPI, LinkerAPI
• MOTDChanger, PermissionCategory, ItemBuilder, etc.
f. External Services
• Discord
• GitHub
• (Potential other HTTP APIs)
Component Relationships & Data Flows
• On plugin load, AywenCraftPlugin reads YAML config → initializes DatabaseManager → registers commands & listeners.
• Player issues a command → Command Dispatcher invokes specific Command class → uses Domain Managers or Utils → may read/write to database or config.
• In-game events → Event Dispatcher sends events to Listeners → they call Domain Managers or Utils (e.g., Insomnia listener sets player state).
• Managers persist data via DatabaseManager or update YAML files.
• Some commands/utilities call External Services via HTTP (DiscordWebhook, GitHubAPI).
Architectural Patterns & Principles
• Event-Driven (Bukkit’s listener model)
• Command Pattern (each plugin command is its own class)
• Layered Architecture:
1) API Layer (commands, listeners)
2) Service Layer (managers)
3) Data Layer (DatabaseManager + YAML config)
4) Integration Layer (external HTTP APIs)
• Single Responsibility: each class handles one behavior (e.g., “FreezeCommand” vs “FreezeListener” vs “FreezeUtils”).