API Reference
Table of Contents
Core API
NexAuthPlugin
The main plugin interface that all plugin implementations must extend.
Methods
getDatabaseProvider() : ReadWriteDatabaseProvider
Returns the database provider instance.
Returns: The configured database provider
Example:
getEventProvider() : EventProvider<P, S>
Returns the event provider for subscribing to and firing events.
Returns: The event provider instance
Example:
getAuthorizationProvider() : AuthorizationProvider<P>
Returns the authorization provider for managing player authentication state.
Returns: The authorization provider
Example:
getLogger() : Logger
Returns the plugin logger.
Returns: The logger instance
getConfiguration() : HoconPluginConfiguration
Returns the plugin configuration.
Returns: The configuration instance
Example:
getMessages() : Messages
Returns the messages manager for localization.
Returns: The messages instance
Example:
getCryptoProvider(String id) : CryptoProvider
Returns a specific crypto provider by identifier.
Parameters:
id- The crypto provider identifier (e.g., "argon2id", "bcrypt2a")
Returns: The crypto provider, or null if not found
Example:
getDefaultCryptoProvider() : CryptoProvider
Returns the default configured crypto provider.
Returns: The default crypto provider
registerCryptoProvider(CryptoProvider provider)
Registers a new crypto provider.
Parameters:
provider- The crypto provider to register
Example:
migrate(ReadDatabaseProvider from, WriteDatabaseProvider to)
Migrates user data from one database provider to another.
Parameters:
from- Source database providerto- Destination database provider
Example:
registerDatabaseConnector(...)
Registers a database connector.
Overloads:
Example:
registerReadProvider(ReadDatabaseProviderRegistration<?, ?, ?> registration)
Registers a read database provider.
Parameters:
registration- The provider registration
Example:
createUser(...) : User
Creates a new user instance.
Parameters:
uuid- The player's UUIDpremiumUUID- The premium UUID (if any)hashedPassword- The hashed passwordlastNickname- The last used nicknamejoinDate- Join timestamplastSeen- Last seen timestampsecret- TOTP secret (if any)ip- IP addresslastAuthentication- Last authentication timestamplastServer- Last server nameemail- Email address
Returns: A new User instance
getPlatformHandle() : PlatformHandle<P, S>
Returns the platform handle for platform-specific operations.
Returns: The platform handle
getParsedVersion() : SemanticVersion
Returns the parsed version of the plugin.
Returns: The semantic version
getServerHandler() : ServerHandler<P, S>
Returns the server handler for server management.
Returns: The server handler
getPremiumProvider() : PremiumProvider
Returns the premium provider.
Returns: The premium provider
getImageProjector() : ImageProjector<P, S>
Returns the image projector for QR code generation.
Returns: The image projector, or null if disabled
getTOTPProvider() : TOTPProvider
Returns the TOTP provider for 2FA operations.
Returns: The TOTP provider, or null if disabled
getEmailHandler() : EmailHandler
Returns the email handler.
Returns: The email handler, or null if disabled
validPassword(String password) : boolean
Validates a password against configuration rules.
Parameters:
password- The password to validate
Returns: True if valid, false otherwise
Example:
checkDataFolder()
Creates the data folder if it doesn't exist.
generateNewUUID(String name, UUID premiumID) : UUID
Generates a new UUID based on configuration.
Parameters:
name- The player namepremiumID- The premium UUID (optional)
Returns: The generated UUID
Example:
floodgateEnabled() : boolean
Checks if Floodgate integration is enabled.
Returns: True if enabled, false otherwise
luckpermsEnabled() : boolean
Checks if LuckPerms integration is enabled.
Returns: True if enabled, false otherwise
fromFloodgate(UUID uuid) : boolean
Checks if a UUID is from Floodgate.
Parameters:
uuid- The UUID to check
Returns: True if from Floodgate, false otherwise
Event System
EventProvider
The event provider manages event subscription, unsubscription, and firing.
Methods
subscribe(EventType<P, S, E> type, Consumer<E> handler) : Consumer<E>
Subscribes to an event.
Type Parameters:
E- The event type
Parameters:
type- The event typehandler- The event handler
Returns: The handler instance (for unsubscription)
Example:
unsubscribe(Consumer<? extends Event<P, S>> handler)
Unsubscribes from an event.
Parameters:
handler- The handler to unsubscribe
Example:
fire(EventType<P, S, E> type, E event)
Fires an event to all subscribers.
Type Parameters:
E- The event type
Parameters:
type- The event typeevent- The event to fire
Example:
getTypes() : EventTypes<P, S>
Returns all available event types.
Returns: The event types container
Event
Base interface for all events.
Methods
getPlugin() : NexAuthPlugin<P, S>
Gets the plugin instance.
Returns: The plugin instance
getPlatformHandle() : PlatformHandle<P, S>
Gets the platform handle.
Returns: The platform handle
CancellableEvent
An event that can be cancelled.
Methods
isCancelled() : boolean
Checks if the event is cancelled.
Returns: True if cancelled, false otherwise
setCancelled(boolean cancelled)
Sets the cancellation state.
Parameters:
cancelled- The cancellation state
Event Types
Available Events
AuthenticatedEvent
Fired when a player is successfully authenticated.
Properties:
player : P- The playeruser : User- The userreason : AuthenticationReason- The authentication reason
AuthenticationReason enum:
LOGIN- Player logged inREGISTER- Player registeredSESSION- Session was usedPREMIUM_AUTO_LOGIN- Automatic premium login
Example:
WrongPasswordEvent
Fired when a player enters wrong password.
Properties:
player : P- The playerattempts : int- Number of attempts
Example:
PasswordChangeEvent
Fired when a player changes password.
Properties:
player : P- The playeroldPassword : String- The old passwordnewPassword : String- The new password
LobbyServerChooseEvent
Fired when choosing lobby server.
Properties:
player : P- The playerserverName : String- The server name (mutable)
Example:
LimboServerChooseEvent
Fired when choosing limbo server.
Properties:
player : P- The playerserverName : String- The server name (mutable)
PremiumLoginSwitchEvent
Fired when switching between premium and offline accounts.
Properties:
player : P- The playeroldUUID : UUID- Old UUIDnewUUID : UUID- New UUIDreason : String- Switch reason
Database API
ReadDatabaseProvider
Interface for reading data from database.
Methods
getByUUID(UUID uuid) : User
Gets a user by UUID.
Parameters:
uuid- The UUID
Returns: The user, or null if not found
Example:
getByName(String name) : User
Gets a user by name.
Parameters:
name- The name (case-insensitive)
Returns: The user, or null if not found
Example:
getAllUsers() : List<User>
Gets all users.
Returns: List of all users
Example:
WriteDatabaseProvider
Interface for writing data to database.
Methods
insertUser(User user)
Inserts a new user.
Parameters:
user- The user to insert
Example:
updateUser(User user)
Updates an existing user.
Parameters:
user- The user to update
Example:
deleteUser(UUID uuid)
Deletes a user.
Parameters:
uuid- The UUID of the user to delete
deleteUser(User user)
Deletes a user.
Parameters:
user- The user to delete
ReadWriteDatabaseProvider
Extends both ReadDatabaseProvider and WriteDatabaseProvider.
User
Represents a user in the database.
Methods
getUUID() : UUID
Returns the UUID.
getPremiumUUID() : UUID
Returns the premium UUID, or null if not premium.
getHashedPassword() : HashedPassword
Returns the hashed password.
getLastNickname() : String
Returns the last used nickname.
getJoinDate() : Timestamp
Returns the join date.
getLastSeen() : Timestamp
Returns the last seen timestamp.
getSecret() : String
Returns the TOTP secret, or null if not set.
getIp() : String
Returns the IP address.
getLastAuthentication() : Timestamp
Returns the last authentication timestamp.
getLastServer() : String
Returns the last server name.
getEmail() : String
Returns the email address, or null if not set.
Setters
All fields have corresponding setters:
setUUID(UUID uuid)setPremiumUUID(UUID uuid)setHashedPassword(HashedPassword password)setLastNickname(String name)setJoinDate(Timestamp timestamp)setLastSeen(Timestamp timestamp)setSecret(String secret)setIp(String ip)setLastAuthentication(Timestamp timestamp)setLastServer(String server)setEmail(String email)
DatabaseConnector
Interface for database connections.
Methods
connect()
Establishes database connection.
disconnect()
Closes database connection.
isConnected() : boolean
Checks if connected.
Returns: True if connected, false otherwise
getConnection() : Connection
Gets the underlying connection.
Returns: The JDBC connection
Supported Database Providers
MySQL
Identifier: nexauth-mysql
Configuration:
PostgreSQL
Identifier: nexauth-postgresql
Configuration:
SQLite
Identifier: nexauth-sqlite
Configuration:
Migration Providers
NexAuth supports migration from various plugins:
AuthMe
authme-mysql, authme-postgresql, authme-sqlite
FastLogin
fastlogin-mysql, fastlogin-sqlite
LogIt
logit-mysql
Aegis
aegis-mysql
DBA
dba-mysql
JPremium
jpremium-mysql
NLogin
nlogin-mysql, nlogin-sqlite
LimboAuth
limboauth-mysql
Authy
authy-mysql, authy-sqlite
LoginSecurity
loginsecurity-mysql, loginsecurity-sqlite
UniqueCodeAuth
uniquecodeauth-mysql
Authorization API
AuthorizationProvider
Manages player authorization state.
Methods
isAuthorized(P player) : boolean
Checks if player is authorized.
Parameters:
player- The player
Returns: True if authorized, false otherwise
Example:
isAwaiting2FA(P player) : boolean
Checks if player is in 2FA setup process.
Parameters:
player- The player
Returns: True if awaiting 2FA confirmation, false otherwise
authorize(User user, P player, AuthenticationReason reason)
Authorizes a player.
Parameters:
user- The userplayer- The playerreason- The authentication reason
Example:
confirmTwoFactorAuth(P player, Integer code, User user) : boolean
Confirms 2FA code.
Parameters:
player- The playercode- The TOTP codeuser- The user
Returns: True if valid, false otherwise
Example:
Crypto API
CryptoProvider
Interface for password hashing and verification.
Methods
createHash(String password) : HashedPassword
Creates a hash from password.
Parameters:
password- Plaintext password
Returns: Hashed password, or null if failed
Example:
matches(String input, HashedPassword password) : boolean
Verifies password against hash.
Parameters:
input- Plaintext passwordpassword- Hashed password
Returns: True if match, false otherwise
Example:
getIdentifier() : String
Gets the algorithm identifier.
Returns: The algorithm name (e.g., "argon2id", "bcrypt2a")
HashedPassword
Represents a hashed password with salt.
Methods
getHash() : String
Returns the hash string.
getSalt() : String
Returns the salt string.
getAlgorithm() : String
Returns the algorithm name.
Supported Algorithms
Argon2ID (Recommended)
Identifier: argon2id
Security Level: ⭐⭐⭐⭐⭐ (Highest)
Features:
Memory-hard algorithm
GPU resistant
Configurable time/memory cost
Configuration:
Example:
BCrypt2A
Identifier: bcrypt2a
Security Level: ⭐⭐⭐⭐ (High)
Features:
Time-cost adjustable
Widely supported
Proven track record
Configuration:
Example:
SHA-256 / SHA-512
Identifiers: sha256, sha512
Security Level: ⭐⭐ (Low) - Legacy only
Warning: Only use for migration purposes. Use Argon2ID or BCrypt2A for new installations.
Example:
LOGIT-SHA-256
Identifier: logit-sha256
Security Level: ⭐⭐ (Low) - Plugin-specific
Features:
Custom algorithm by LogIt plugin
Only for migration
Custom Crypto Provider
Implement custom algorithm:
Configuration API
HoconPluginConfiguration
Manages plugin configuration using HOCON format.
Methods
get(Key<T> key) : T
Gets a configuration value.
Type Parameters:
T- The value type
Parameters:
key- The configuration key
Returns: The configuration value
Example:
set(Key<T> key, T value)
Sets a configuration value.
Type Parameters:
T- The value type
Parameters:
key- The configuration keyvalue- The value to set
Example:
reload(NexAuthPlugin<P, S> plugin) : boolean
Reloads configuration from file.
Parameters:
plugin- The plugin instance
Returns: True if new config generated, false otherwise
Example:
save()
Saves configuration to file.
ConfigurationKeys
Contains all configuration keys.
Database Configuration
DATABASE_TYPE : Key<String>
Database provider type (e.g., "nexauth-mysql")
DATABASE_MYSQL_* : Key<*>
MySQL-specific configuration:
DATABASE_MYSQL_HOST : Key<String>DATABASE_MYSQL_PORT : Key<Integer>DATABASE_MYSQL_DATABASE : Key<String>DATABASE_MYSQL_USERNAME : Key<String>DATABASE_MYSQL_PASSWORD : Key<String>DATABASE_MYSQL_POOL_SIZE : Key<Integer>
Similar keys for PostgreSQL and SQLite
Authentication Configuration
MAX_LOGIN_ATTEMPTS : Key<Integer>
Maximum login attempts before temporary ban.
Default: 5
TEMP_BAN_DURATION : Key<Long>
Temporary ban duration in milliseconds.
Default: 300000 (5 minutes)
SESSION_TIMEOUT : Key<Long>
Session timeout in milliseconds.
Default: 3600000 (1 hour)
MINIMUM_PASSWORD_LENGTH : Key<Integer>
Minimum password length.
Default: 8
2FA Configuration
TOTP_ENABLED : Key<Boolean>
Enable/disable 2FA.
Default: false
TOTP_ISSUER : Key<String>
TOTP issuer name.
Default: "NexAuth"
Email Configuration
MAIL_ENABLED : Key<Boolean>
Enable/disable email functionality.
Default: false
MAIL_HOST : Key<String>
SMTP server host.
MAIL_PORT : Key<Integer>
SMTP server port.
MAIL_USERNAME : Key<String>
SMTP username.
MAIL_PASSWORD : Key<String>
SMTP password.
MAIL_FROM : Key<String>
From address.
Server Configuration
LIMBO : Key<List<String>>
List of limbo servers.
LOBBY : Key<Multimap<String, String>>
Lobby server configuration.
DEFAULT_LOBBY : Key<String>
Default lobby server.
REMEMBER_LAST_SERVER : Key<Boolean>
Remember last server for each player.
Default: true
Crypto Configuration
DEFAULT_CRYPTO_PROVIDER : Key<String>
Default crypto provider identifier.
Default: "argon2id"
See Crypto API for provider-specific settings
HoconMessages
Manages localized messages.
Methods
getMessage(String key, String... replacements) : TextComponent
Gets a message by key with replacements.
Parameters:
key- The message keyreplacements- Placeholder replacements
Returns: The formatted message
Example:
reload(NexAuthPlugin<?, ?> plugin)
Reloads messages from file.
Message Keys
Authentication
login.success- Successful loginlogin.welcome- Welcome messagelogin.wrong-password- Wrong password errorregister.success- Successful registrationregister.need-confirm- Password confirmation requiredregister.password-mismatch- Passwords don't match
2FA
totp.enabled- 2FA enabled messagetotp.disabled- 2FA disabled messagetotp.code-required- Code required messagetotp.invalid-code- Invalid code error
Email
mail.sent- Email sent confirmationmail.verified- Email verified confirmationmail.reset-sent- Password reset email sent
Errors
error.player-not-found- Player not founderror.permission-denied- Permission deniederror.command-disabled- Command disablederror.database-error- Database error
Server Management API
ServerHandler
Manages player server routing.
Methods
chooseLobby(P player) : String
Chooses a lobby server for player.
Parameters:
player- The player
Returns: The chosen lobby server name
Example:
chooseLimbo(P player) : String
Chooses a limbo server for player.
Parameters:
player- The player
Returns: The chosen limbo server name
sendToLobby(P player)
Sends player to lobby.
Parameters:
player- The player
Example:
sendToLimbo(P player)
Sends player to limbo.
Parameters:
player- The player
getBestServer(String serverName) : String
Gets the best server from a group.
Parameters:
serverName- The server name
Returns: The best server identifier
getPlayersServerName(P player) : String
Gets the server name for a player.
Parameters:
player- The player
Returns: The server name, or null if not found
ServerPing
Represents server ping information.
Methods
getName() : String
Returns the server name.
getPlayers() : int
Returns number of players.
getMaxPlayers() : int
Returns maximum players.
getLatency() : int
Returns latency in milliseconds.
getMotd() : String
Returns the MOTD.
getVersion() : String
Returns the version.
Premium API
PremiumProvider
Manages premium account integration.
Methods
getUserForName(String username) : PremiumUser
Gets premium user by name.
Parameters:
username- The username
Returns: The premium user
Example:
getUserForUUID(UUID uuid) : PremiumUser
Gets premium user by UUID.
Parameters:
uuid- The UUID
Returns: The premium user
isPremium(UUID uuid) : boolean
Checks if UUID is premium.
Parameters:
uuid- The UUID
Returns: True if premium, false otherwise
PremiumUser
Represents a premium user.
Methods
getUUID() : UUID
Returns the UUID.
getName() : String
Returns the username.
isOnline() : boolean
Checks if player is online.
Returns: True if online, false otherwise
getProperties() : Map<String, String>
Returns player properties.
PremiumException
Exception for premium operations.
Methods
getIssue() : Issue
Returns the issue type.
Issue enum:
THROTTLED- Too many requestsOFFLINE- Mojang services offlineNOT_PREMIUM- Account not premiumUNKNOWN- Unknown error
TOTP API
TOTPProvider
Manages TOTP (Time-based One-Time Password) for 2FA.
Methods
generateSecret() : String
Generates a new secret.
Returns: The secret string
Example:
generateQRCode(String secret, String username, String issuer) : BufferedImage
Generates QR code for authenticator apps.
Parameters:
secret- The TOTP secretusername- The usernameissuer- The issuer name
Returns: QR code image
Example:
verifyCode(String secret, int code) : boolean
Verifies a TOTP code.
Parameters:
secret- The secretcode- The code to verify
Returns: True if valid, false otherwise
Example```java String secret = user.getSecret(); int code = Integer.parseInt(codeString);
boolean isValid = totpProvider.verifyCode(secret, code); if (isValid) { // Code valid } else { // Invalid code }
unregisterCommands(Object commandClass)
Unregisters command class.
Parameters:
commandClass- The command class
Command Structure
NexAuth uses ACF (Aikar Command Framework) for commands.
Base Command Classes
AuthorizationCommand-/login,/register,/changepasswordTwoFactorAuthCommand-/2fa enable,/2fa confirmPremiumCommand-/premium enable,/premium confirmEMailCommand-/mail set,/mail verifyStaffCommand-/nexauth reload,/nexauth migrateChangePasswordCommand- Password change
Custom Commands
Create custom command:
Annotations:
@CommandPermission- Required permission@CommandCompletion- Tab completion@Default- Default command@Subcommand- Subcommand@Optional- Optional parameter@Flags- Command flags
Mail API
EmailHandler
Manages email sending.
Methods
sendEmail(String to, String subject, TextComponent content)
Sends an email.
Parameters:
to- Recipient emailsubject- Email subjectcontent- Email content
Example:
sendPasswordResetEmail(String email, String code)
Sends password reset email.
Parameters:
email- Recipient emailcode- Reset code
sendVerificationEmail(String email, String code)
Sends verification email.
Parameters:
email- Recipient emailcode- Verification code
PlatformHandle
Platform-specific operations interface.
Methods
getPlatformIdentifier() : String
Returns platform identifier ("bungeecord", "velocity", "paper")
getUUIDForPlayer(P player) : UUID
Gets player UUID.
Parameters:
player- The player
Returns: The UUID
getNameForPlayer(P player) : String
Gets player name.
Parameters:
player- The player
Returns: The name
getPlayersServerName(P player) : String
Gets server name for player.
Parameters:
player- The player
Returns: The server name
sendMessage(P player, TextComponent message)
Sends message to player.
Parameters:
player- The playermessage- The message
kickPlayer(P player, TextComponent reason)
Kicks player.
Parameters:
player- The playerreason- Kick reason
getIP(P player) : String
Gets player IP address.
Parameters:
player- The player
Returns: The IP address
connect(P player, String server)
Connects player to server.
Parameters:
player- The playerserver- Server name
Logger
Simple logger interface.
Methods
info(String message)
Logs info message.
warn(String message)
Logs warning message.
error(String message)
Logs error message.
error(String message, Throwable throwable)
Logs error with stack trace.
debug(String message)
Logs debug message (if enabled).
Utility Classes
SemanticVersion
Represents semantic version.
Methods
parse(String version) : SemanticVersion
Parses version string.
compare(SemanticVersion other) : int
Compares versions.
Returns: Negative if this < other, 0 if equal, positive if this > other
dev() : boolean
Checks if development build.
Returns: True if dev build, false otherwise
ThrowableFunction
Functional interface for functions that throw exceptions.
ThrowableConsumer
Functional interface for consumers that throw exceptions.
BiHolder
Simple tuple holding two values.
Integration Guide
Custom Event Listener
Custom Database Provider
Best Practices
1. Always Use Async Operations
2. Handle Errors Gracefully
3. Use Event System
4. Validate Inputs
5. Use Type-Safe Configuration
Common Patterns
Permission Check
Player Validation
Async Task Execution
Configuration Reload
Error Codes
1001
InvalidCredentials
Wrong username or password
1002
UserNotFound
User doesn't exist
1003
UserExists
User already exists
1004
PasswordTooShort
Password doesn't meet requirements
1005
PasswordWeak
Password is too weak
1006
TooManyAttempts
Too many login attempts
1007
2FARequired
2FA code required
1008
2FAInvalid
Invalid 2FA code
1009
EmailInvalid
Invalid email address
1010
DatabaseError
Database operation failed
1011
PermissionDenied
Missing permission
1012
CommandDisabled
Command is disabled
1013
PremiumOnly
Feature only for premium users
1014
ServerOffline
Server is offline
1015
NetworkError
Network operation failed
Examples
Full Authentication Flow
Custom Event Handler
Performance Tips
1. Use Connection Pooling
2. Batch Database Operations
3. Cache Frequently Used Data
4. Use Async Operations
5. Avoid N+1 Queries
Security Considerations
1. Never Store Plaintext Passwords
2. Use Prepared Statements
3. Validate All Inputs
4. Use Event Cancellation
Troubleshooting
Common Issues
Issue: User is always redirected to limbo
Cause: Authorization state not properly set
Solution:
Issue: Database connection timeouts
Cause: Connection pool exhausted
Solution:
Issue: 2FA codes not working
Cause: Time drift between server and authenticator
Solution:
Issue: Players can join backend servers directly
Cause: Backend servers not secured
Solution:
Use BungeeGuard
Configure firewall rules
Only allow proxy IP addresses
Use NexLimbo for authentication
Changelog
Version 0.0.1-beta3
Added:
Argon2ID support
Event system improvements
MySQL, PostgreSQL, SQLite support
TOTP 2FA
Email verification
Migration from multiple plugins
For full changelog, see CHANGELOG.md
References
License
NexAuth API is licensed under the Mozilla Public License 2.0.
See LICENSE for details.
This API reference is automatically generated from source code. For the latest updates, visit the GitHub repository.
Last updated
