How topper-mc/chattopper works
Primary Components
• Main Plugin Class: At the center is ChatTopper.java—the entry point of the plugin that initializes and registers all other components during the plugin’s startup.
• Command Handling: The GetWordTopCommand.java class deals with the “/getwordtop” command. This is important since it provides user interaction to fetch the leaderboard items.
• Chat Listening: ChatListener.java listens to chat messages (through the Bukkit event system) and relays data to be processed.
• Word Holders & Update Agents: WordHolder.java (and its related update agent in the agent sub-package) maintain the current count/state of words.
• Managers: There are several manager classes:
• HolderManager.java: Likely oversees the lifecycle and state of word data.
• StorageManager.java: Might deal with saving/loading persisted data.
• WordQueryManager.java and WordQueryForward.java: Likely responsible for handling queries against the stored data to produce ordered leaderboard results.
• Placeholder Integration: PlaceholderHook.java registers and handles placeholders (e.g., %chattopper_top_key;<index>%), allowing external systems or other plugin components to access leaderboard details.
b. Components & Their Roles:
• Plugin Bootstrap: ChatTopper.java
• Event Listener: ChatListener.java (connected to the main plugin to receive chat events)
• Command Interface: GetWordTopCommand.java (receives user commands, typically via Bukkit’s command registration)
• Data Holders & Agents: WordHolder.java and UpdateAgent.java (handle in-memory word tracking and periodic updates)
• Managers:
• HolderManager.java (coordinates the overall word tracking)
• StorageManager.java (handles persistence, suggesting data storage flow)
• WordQueryManager.java & WordQueryForward.java (process leaderboard retrieval from word data)
• Integration Hooks: PlaceholderHook.java (exposes data externally via placeholders)
c. Relationships & Data Flow:
• The ChatListener is triggered by Minecraft chat events; it passes word data or events to the HolderManager.
• The HolderManager updates the WordHolder and might delegate to the UpdateAgent for periodic updates.
• When a player enters the command (/getwordtop), the GetWordTopCommand accesses the WordQueryManager (and/or WordQueryForward) to retrieve and format leaderboard data.
• The PlaceholderHook subscribes to external calls for placeholder data, calling into WordQueryManager or the stored data to return the word or count.
• StorageManager is connected edge-wise with managers to perform any load or save operations as needed.
d. Architectural & Design Patterns:
• Event Driven: ChatListener reacting to in-game events.
• Modularization: Separation of concerns between handling commands, managing state, and offering external hooks.
• Dependency Injection (possibly through the plugin framework): Components are likely registered via the main plugin class.
• Use of Managers for centralized coordination.
e. Technologies & Frameworks:
• Bukkit/Spigot API (implicit because of the plugin structure and plugin.yml file)
• Maven (as indicated by the pom.xml)
Final Reminders
• All components should be clearly labeled along with brief notes on their role.
• Similarly purposed components to make the architectural flow intuitive.