Developer Guide
Table of Contents
Introduction
This guide is for developers who want to:
Extend NexAuth with custom functionality
Integrate NexAuth with other plugins
Contribute to the NexAuth project
Build custom features on top of NexAuth
Prerequisites
Java 21 or newer
Maven or Gradle
Git
Basic understanding of Minecraft plugin development
Knowledge of design patterns (Observer, Strategy, Factory)
What You'll Learn
How to set up development environment
How to build NexAuth from source
How to extend NexAuth's functionality
How to create custom database providers
How to listen to and fire events
How to integrate with other plugins
Development Environment Setup
Step 1: Install Java 21
Linux (Ubuntu/Debian):
Windows:
Download OpenJDK 21 from Adoptium
Run installer
Verify in Command Prompt:
java -version
macOS:
Step 2: Install Git
Linux:
Windows: Download from git-scm.com
macOS:
Step 3: Clone Repository
Step 4: Set Up IDE
IntelliJ IDEA (Recommended)
Download IntelliJ IDEA Community Edition
Open project:
Import Gradle project when prompted
Wait for indexing to complete
Eclipse
Install BuildShip Gradle plugin
Import as Gradle project
Select project root directory
Step 5: Verify Setup
Build the project:
Should see:
Project Structure
Module Breakdown
API Module
Contains interfaces only - no implementations. This is what other plugins use to integrate with NexAuth.
Key Interfaces:
NexAuthPlugin- Main plugin interfaceEventProvider- Event systemReadDatabaseProvider- Database read operationsWriteDatabaseProvider- Database write operationsAuthorizationProvider- Authentication managementCryptoProvider- Password hashing
Plugin Module
Contains implementations for specific platforms (BungeeCord, Velocity, Paper).
Key Classes:
AuthenticNexAuth- Main implementationAuthenticDatabaseProvider- Database implementationAuthenticEventProvider- Event implementationAuthenticAuthorizationProvider- Authorization implementation
Building from Source
Using Gradle
Build Outputs
After successful build:
Running Tests
Publishing to Local Maven
API Overview
Core Interfaces
NexAuthPlugin
Main interface that all plugin implementations extend.
Key Methods:
EventProvider
Manages event system (Observer pattern).
ReadDatabaseProvider
Read operations from database.
WriteDatabaseProvider
Write operations to database.
ReadWriteDatabaseProvider
Combined read/write interface.
AuthorizationProvider
Manages player authorization state.
CryptoProvider
Password hashing interface.
Event System
Event Types
NexAuth provides numerous event types:
AuthenticatedEvent- Player authenticatedWrongPasswordEvent- Wrong password enteredPasswordChangeEvent- Password changedLobbyServerChooseEvent- Choosing lobby serverLimboServerChooseEvent- Choosing limbo serverPremiumLoginSwitchEvent- Premium UUID switch
Event Structure
CancellableEvent
Events that can be cancelled by listeners.
Extending NexAuth
Creating a Custom Plugin Extension
Step 1: Create Project
Step 2: Setup build.gradle
Step 3: Implement Integration
Creating a BungeeCord Plugin with NexAuth Integration
Step 1: Create bungee.yml
Step 2: Create Plugin Class
Creating a Paper Plugin with NexAuth Integration
Step 1: Create plugin.yml
Step 2: Create Plugin Class
Custom Database Providers
Create a custom database provider for unsupported databases or specific requirements.
Example: Redis-Based Provider
Step 1: Implement DatabaseConnector
Step 2: Implement ReadDatabaseProvider
Step 3: Implement WriteDatabaseProvider
Step 4: Combine Providers
Step 5: Register Provider
Step 6: Configure in config.conf
Example: File-Based Provider (JSON)
For simple setups or testing:
Custom Event Handlers
Listen to NexAuth events to integrate with your plugin.
Example: Reward System
Example: Integration with Discord
Creating Custom Events
Create custom events for your extension:
Custom Crypto Providers
Create custom password hashing algorithms.
Example: Custom Pepper-Based Hashing
Register Custom Crypto Provider
Advanced: Memory-Hard KDF
Plugin Integration
Integration Checklist
When integrating with NexAuth:
Add Dependency: Depend on NexAuth API
Check for NexAuth: Verify NexAuth is present and enabled
Subscribe to Events: Listen to relevant events
Handle Errors: Gracefully handle NexAuth not being present
Unregister: Clean up event listeners on disable
Example: ChestShop Integration
Integration Example: Vault Economy
Testing Integration
Testing
Unit Testing Database Providers
Mock NexAuth Plugin for Testing
Integration Testing
Testing Utilities
Contributing
Contribution Guidelines
We welcome contributions to NexAuth! Here's how to contribute:
Types of Contributions
🐛 Bug fixes
✨ New features
📚 Documentation improvements
🧪 Test coverage improvements
💡 Performance optimizations
🔧 Code refactoring
Before You Start
Check existing issues and PRs
Create an issue to discuss large changes
Ask questions in Discord if unsure
Development Workflow
Fork the repository
Clone your fork:
Create a feature branch:
Make your changes
Test thoroughly:
Commit with clear messages:
Push to your fork:
Open a Pull Request
Code Style
Follow Google Java Style Guide
Use meaningful variable names
Write JavaDoc for public methods
Keep methods focused and small
Use interfaces for abstraction
Commit Message Format
Use conventional commits:
Types:
feat: New featurefix: Bug fixdocs: Documentation changesrefactor: Code refactoringtest: Test changeschore: Build process, dependency updates
Examples:
Pull Request Template
Running Tests
Building Documentation
If you make changes to the API:
Code Review Process
Automated checks must pass (CI)
At least one reviewer approval required
Address feedback and push changes
Squash commits before merging (if requested)
Getting Help
Discord: https://discord.gg/m5ptM8X2Du
GitHub Issues: https://github.com/xreatlabs/NexAuth/issues
GitHub Discussions: https://github.com/xreatlabs/NexAuth/discussions
Best Practices
Design Patterns
Use Observer Pattern for Events
Use Strategy Pattern for Providers
Use Factory Pattern for Object Creation
Error Handling
Handle Exceptions Gracefully
Use Specific Exceptions
Performance
Use Async Operations
Batch Database Operations
Cache Frequently Used Data
Security
Never Store Plaintext Passwords
Validate All Inputs
Use Prepared Statements
Code Organization
Keep Methods Small and Focused
Use Dependency Injection
Document Public APIs
Testing
Write Unit Tests
Use Mocks for Testing
Test Integration Points
Logging
Use Appropriate Log Levels
Include Context in Logs
Configuration
Use Type-Safe Configuration
Validate Configuration
Example Projects
Looking for examples? Check out these projects:
Official Extensions
NexLimbo: https://github.com/Xreatlabs/NexLimbo
Optimized limbo server
Official NexAuth companion
Community Extensions
(Feel free to add your project here by opening a PR)
Resources
Documentation
APIs and Libraries
Tools
Testing
Support
Getting Help
GitHub Issues: Report bugs or request features
Discord: Join our community
GitHub Discussions: Ask questions
Professional Support
For commercial support or consulting:
Contact us on Discord
Email: [contact information]
Version: 0.0.1-beta3 Last Updated: 2025-10-30 Maintainers: Xreatlabs Team
Happy coding! 🚀
Last updated
