How luddang/minecollector works
Project type and purpose
• This is a Minecraft server plugin (“MineCollector”) written in Java (with a small Kotlin micro-service) that tracks and scores item collections, advancements, and exposes commands/GUI to players.
• Its goal is to run inside a Bukkit/Spigot server, listen to in-game events, persist player data, offer commands (collect, book, check, ranking, guide), auto-save data, and optionally sync across servers via a separate Kotlin SyncServer.
File structure
• Top-level build files (build.gradle, settings.gradle, gradlew) configure a Gradle-based Java project with a Kotlin submodule.
• src/main/java/com/doubledeltas/minecollector: core plugin code
• MineCollector.java – plugin entry point
• GameDirector.java – central orchestrator
• config/… – ConfigManager, McolConfig (reads config.yml)
• data/… – DataManager, GameData, ExtendedGameData, DataAutoSaver
• command/… – CommandRoot, CommandNode, concrete commands (BookCommand, CollectCommand, etc.)
• listener/… – EventManager, various Bukkit event listeners
• gui/… – GUI screens using Bukkit inventories
• item/… – ItemManager, ItemBuilder, item-code abstractions
• util/… – helper classes (Yamls, MessageUtil, etc.)
• src/main/kotlin/live/luya/minecollector: external sync server (MineCollectorSyncServer.kt)
• src/main/resources: config.yml, plugin.yml, item definitions
README insights
• Describes scoring rules, commands, auto-save every 10 minutes, configurable via config.yml, and a hook for dropping ender eggs.
a. Main components:
1. Bukkit/Spigot Server (platform)
2. Plugin Loader & Lifecycle (calls onEnable/onDisable in MineCollector.java)
3. GameDirector (plugin core)
4. ConfigManager (loads config.yml → McolConfig, chapters)
5. EventManager & Listeners (player events, entity deaths, advancements)
6. CommandRoot & CommandNodes (parses and dispatches commands)
7. DataManager & DataAutoSaver (holds per-player GameData, flushes to YAML)
8. GUI Module (HubGui, CollectionGui, DumpGui)
9. Item Module (ItemManager, ItemBuilder, itemCode strategy)
10. Utility Layer (Yamls, MessageUtil, SoundUtil)
11. External Sync Server (MineCollectorSyncServer – optional network sync)
12. Persistence Storage (flat YAML files in plugin folder)
b. Relationships & interactions:
• On plugin enable → GameDirector initializes ConfigManager, DataManager, registers EventManager, registers command handlers (CommandRoot).
• Bukkit events → forwarded to EventManager → individual Listeners → update GameData via DataManager → may fire TotalScoreModifiedEvent.
• Player issues a command → Bukkit hands off to CommandRoot → selects Concrete CommandNode → executes logic (reads/writes GameData, sends messages, opens GUI).
• GUI opens an Inventory screen → player clicks → GUI module handles click events via registered listeners.
• DataAutoSaver scheduled task every N minutes → invokes DataManager.saveAll() → writes YAML files to disk via Yamls util.
• (Optional) For cross-server sync → plugin TCP/HTTP client communicates with MineCollectorSyncServer → exchanges serialized data via GsonDateConverter.
c. Architectural patterns & principles:
• Event-Driven (Bukkit events → custom events → listeners)
• Command Pattern (CommandRoot/CommandNode hierarchy)
• Singleton/Manager classes for cross-cutting services (ConfigManager, DataManager, EventManager)
• Layered separation: Core → Commands/Listeners → Managers → Persistence → Resources
• Strategy pattern in itemCode (GuiItem, StaticItem)
d. Key technologies & frameworks:
• Java 17, Bukkit/Spigot API
• Gradle build, Kotlin + kotlinx for SyncServer
• SnakeYAML (via Yamls utility) for config/data
• GsonDateConverter for JSON date handling
• Bukkit scheduler for auto-save
Final advice
• Be exhaustive: include all subsystems (Config, Command, Event, Data, GUI, Item, Util, Sync).
• Clearly demarcate boundaries: Plugin vs. Host Server vs. External Sync Service vs. File System.
• Data flows (player actions → plugin → storage → back to player).