How papermc/velocity works
Main Components
• API Module: This module (located under “api”) contains the public interfaces for plugins, events, commands, network communication, scheduling, and utilities. It defines core abstractions such as Plugin, ProxyServer, CommandManager, EventManager, etc.
• Proxy Module: The “proxy” directory represents the main runtime for the proxy itself. This module handles network connections, session handling, command processing, player connections, and routing to backend servers.
• Native Module: Under “native”, this part focuses on native code integrations (written in C, JNI components) for performance-critical tasks such as encryption, compression, and other low-level operations.
• Build and Configuration: The configuration files include Gradle build scripts, checkstyle configurations, and other build‐logic, emphasizing that Velocity is built using Gradle with clear separation of concerns among modules.
• Additional Components: The existence of dedicated directories for command handling, event modules, encryption/decryption, and plugin loading (including support for plugin annotation processing in the API) indicates that the design leverages event-driven and plugin-based extensibility.
Relationships and Interactions
• The API defines interfaces that are implemented by the Proxy and other modules – for example, your ProxyServer relies on Plugin, Event, and Command APIs.
• The Proxy module interacts directly with network layers, receiving client connections, handling protocols, and routing packets. It uses events and commands defined in the API.
• The Native module acts as a performance “accelerator” for both the proxy and API layers by providing optimized native implementations that the proxy can call when necessary.
Architectural Patterns and Design Principles
• Modularization: The project is split into clearly demarcated modules (api, proxy, native) that can be updated and maintained separately.
• Plugin-based Extensibility: With dedicated API packages for plugin management and plugin description, there’s a strong emphasis on runtime extensibility.
• Separation of Concerns: Networking, command handling, plugin management, and native operations are each encapsulated in their own layers.
Relevant Technologies and Frameworks
• Java and Gradle: The project is built in Java using Gradle (as indicated by the build.gradle.kts files and Gradle wrapper).
• JNI/Natives: For performance enhancements, the native module integrates C code for encryption and compression.
• Minecraft-specific Protocol Handling: Custom packet classes, protocol utilities, and event structures show that it’s tightly integrated with Minecraft’s networking and protocol conventions.