How achang0611/moneycardkotlinreloaded works
Main Components
• Plugin Entry Point & Configuration:
– The plugin.yml in src/main/resources defines metadata and the entry point.
– The main class (for instance, MoneyCardKotlin.kt) is where the plugin is bootstrapped.
• Minecraft API Integration Layer:
– This includes the classes under the “minecraft” package (e.g., ChatFormatter, InventoryEditor, Permissions, Sender) and sub-components like Commands and Events.
– Commands are organized under commands (with executors such as GetCard, GiveCard, ReloadPlugin) and event listeners (Atomic event handlers like AntiCardCrafting, AntiCardTrading, CardChangeToMoneyEvent) which interface directly with Minecraft’s server API.
• Domain Business Logic Layer:
– Found in the “logic” package, this layer holds classes like Bank, CardConverter, CardDetector, CardFactory, CardInfoValidator, etc.
– It encapsulates the core functionalities, data processing, and rules for handling “cards” (including persistent data handling via MoneyCardPersistentData.kt).
• Utility Components:
– The “utils” package provides helper classes for tasks such as error handling, JSON management (JsonManager), resource I/O, and string formatting.
• Resources & Configuration:
– Several JSON files (card_item_setting.json, create_card_rules.json, message.json) provide configuration and rules that the plugin uses at runtime.
– Build and project configuration files (gradle.build.kts, settings.gradle.kts, etc.) support the build and deployment process.
Relationships and Interactions
• The Plugin Entry Point initializes and registers the components in the Minecraft API Integration layer.
• When Minecraft events occur (e.g., a player issuing a command or an in-game event like crafting), the respective event listeners or command executors are triggered.
• These handlers then delegate to the Domain Business Logic layer (logic package) to process the request (for example, validating a card using CardInfoValidator or creating a card through CardFactory).
• The business logic might in turn interact with the Utility layer for tasks like reading JSON configuration, logging errors, or formatting strings.
• Finally, changes to game state or card data are applied back to the Minecraft environment via the integration layer.
Recognize Key Architectural Patterns
• Layered Architecture: Clear separation between the Minecraft-specific integration (controllers/handlers) and core business logic.
• Modularity: Separation of concerns between command handling, game event processing, and card management logic.
• Extensibility: The design (separating logic, commands, events, and utilities) supports easy future expansion. For example, adding new card types or event handlers without intermixing concerns.