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:

  1. Download OpenJDK 21 from Adoptium

  2. Run installer

  3. 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

  1. Download IntelliJ IDEA Community Edition

  2. Open project:

  3. Import Gradle project when prompted

  4. Wait for indexing to complete

Eclipse

  1. Install BuildShip Gradle plugin

  2. Import as Gradle project

  3. 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 interface

  • EventProvider - Event system

  • ReadDatabaseProvider - Database read operations

  • WriteDatabaseProvider - Database write operations

  • AuthorizationProvider - Authentication management

  • CryptoProvider - Password hashing

Plugin Module

Contains implementations for specific platforms (BungeeCord, Velocity, Paper).

Key Classes:

  • AuthenticNexAuth - Main implementation

  • AuthenticDatabaseProvider - Database implementation

  • AuthenticEventProvider - Event implementation

  • AuthenticAuthorizationProvider - 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 authenticated

  • WrongPasswordEvent - Wrong password entered

  • PasswordChangeEvent - Password changed

  • LobbyServerChooseEvent - Choosing lobby server

  • LimboServerChooseEvent - Choosing limbo server

  • PremiumLoginSwitchEvent - 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:

  1. Add Dependency: Depend on NexAuth API

  2. Check for NexAuth: Verify NexAuth is present and enabled

  3. Subscribe to Events: Listen to relevant events

  4. Handle Errors: Gracefully handle NexAuth not being present

  5. 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

  1. Check existing issues and PRs

  2. Create an issue to discuss large changes

  3. Ask questions in Discord if unsure

Development Workflow

  1. Fork the repository

  2. Clone your fork:

  3. Create a feature branch:

  4. Make your changes

  5. Test thoroughly:

  6. Commit with clear messages:

  7. Push to your fork:

  8. Open a Pull Request

Code Style

  • 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 feature

  • fix: Bug fix

  • docs: Documentation changes

  • refactor: Code refactoring

  • test: Test changes

  • chore: Build process, dependency updates

Examples:

Pull Request Template

Running Tests

Building Documentation

If you make changes to the API:

Code Review Process

  1. Automated checks must pass (CI)

  2. At least one reviewer approval required

  3. Address feedback and push changes

  4. 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

  1. 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

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