Commands and Permissions
Relevant source files
The following files were used as context for generating this wiki page:- Plugin/src/main/java/xyz/xreatlabs/nexauth/common/command/CommandProvider.java
- Plugin/src/main/java/xyz/xreatlabs/nexauth/common/command/Command.java
- Plugin/src/main/java/xyz/xreatlabs/nexauth/common/command/commands/staff/NexAuthCommand.java
- Plugin/src/main/java/xyz/xreatlabs/nexauth/common/command/commands/staff/StaffCommand.java
- Plugin/src/main/java/xyz/xreatlabs/nexauth/common/command/commands/authorization/AuthorizationCommand.java
- Plugin/src/main/java/xyz/xreatlabs/nexauth/common/config/ConfigurationKeys.java
- Plugin/src/main/java/xyz/xreatlabs/nexauth/common/config/MessageKeys.java
- CHANGELOG.md
NexAuth utilizes Aikar's Command Framework (ACF) to provide a robust and extensible command system. Commands are categorized for players (authorization, 2FA, email) and staff (administration, user management). The system is managed by the CommandProvider, which handles command registration, context injection, rate limiting, and exception handling.
Permissions are granular, allowing server administrators to control access to every feature. Most administrative commands are grouped under the /nexauth base command, with permissions following a nexauth.user.<action> or similar pattern. Note that permission nodes were updated from the librepremium.* prefix to nexauth.* in version 0.0.1-beta2.
Command Architecture
The command structure is built upon a hierarchy of base classes that provide common functionality to all command implementations.
Core Components
CommandProvider: The central hub for the command system. It initializes the ACFCommandManager, registers all command classes, injects custom contexts (likeAudience), and handles command-related message localization frommessages.conf. It also implements a 1-second rate limit per user for all commands.
Sources: Plugin/src/main/java/xyz/xreatlabs/nexauth/common/command/CommandProvider.java:38-42, 50-53Command<P>: The abstract base class for all NexAuth commands. It provides convenient access to core plugin components like the database provider, message configuration, and authorization provider. It also includes helper methods for asynchronous execution and user data retrieval.
Sources: Plugin/src/main/java/xyz/xreatlabs/nexauth/common/command/Command.java:23-25StaffCommand<P>: ExtendsCommand<P>and adds helper methods specific to staff actions, such as retrieving a user by name (getUserOtherWiseInform) and asserting a player's online/offline status (requireOffline,requireOnline).
Sources: Plugin/src/main/java/xyz/xreatlabs/nexauth/common/command/commands/staff/StaffCommand.java:16-18AuthorizationCommand<P>: ExtendsCommand<P>with helpers for authorization-related checks, like ensuring a player is not already logged in (checkUnauthorized).
Sources: Plugin/src/main/java/xyz/xreatlabs/nexauth/common/command/commands/authorization/AuthorizationCommand.java:16-18
Class Hierarchy
The following diagram illustrates the inheritance structure of the command classes.
Command Registration Flow
The CommandProvider registers all available commands during plugin initialization. This process is conditional based on enabled features in the configuration (e.g., TOTP and Email commands).
Player Commands
These commands are intended for use by all players for authentication and account management.
| Command | Alias | Description |
|---|---|---|
/login <password> [2fa_code] | /l, /log | Logs the player into their account. |
/register <password> <passwordRepeat> | /reg | Registers a new account for the player. |
/changepassword <oldPassword> <newPassword> | Changes the player's password. | |
/premium <password> | Initiates the process to enable premium auto-login. | |
/confirmpremium | Confirms enabling premium auto-login. | |
/cracked | Disables premium auto-login. | |
/2fa | Starts the 2FA setup process. | |
/2faconfirm <code> | Confirms 2FA setup with a code. | |
/setemail <address> <password> | Sets a recovery email for the account. | |
/verifyemail <code> | Verifies the email address with a code. | |
/resetpassword | Initiates a password reset via email. | |
/confirmpasswordreset <code> <newPassword> <newPasswordRepeat> | Completes the password reset process. |
Sources: Plugin/src/main/java/xyz/xreatlabs/nexauth/common/command/CommandProvider.java:108-124, Plugin/src/main/java/xyz/xreatlabs/nexauth/common/config/MessageKeys.java:622-750
Unauthenticated Commands
A specific list of commands can be executed by players who are not yet authenticated. This is configured via allowed-commands-while-unauthorized in config.yml.
Default Allowed Commands:
login,l,logregister,reg2fa,2faconfirmresetpassword,confirmpasswordreset
Sources: Plugin/src/main/java/xyz/xreatlabs/nexauth/common/config/ConfigurationKeys.java:19-32
Staff Commands (/nexauth)
The /nexauth command is the primary tool for server administrators to manage the plugin and its users. All subcommands require specific permissions.
Sources: Plugin/src/main/java/xyz/xreatlabs/nexauth/common/command/commands/staff/NexAuthCommand.java
General Subcommands
| Subcommand | Permission | Description |
|---|---|---|
about | (none) | Displays plugin version and information. |
dump | nexauth.dump | Creates a JSON dump file with server, plugin, and thread information for debugging. |
reload configuration | librepremium.reload.configuration | Reloads the main config.yml file. |
reload messages | librepremium.reload.messages | Reloads the messages.conf file. |
email test <email> | nexauth.email.test | Sends a test email to the specified address. |
Note: The permissions for reload commands still use the old librepremium prefix. This is likely an oversight.
Sources: Plugin/src/main/java/xyz/xreatlabs/nexauth/common/command/commands/staff/NexAuthCommand.java:43-211, CHANGELOG.md:46-47
User Management Subcommands
These commands are used to manage individual user accounts.
| Subcommand | Permission | Description |
|---|---|---|
user info <name> | librepremium.user.info | Displays detailed information about a user's account. |
user alts <name> | nexauth.user.alts | Lists all accounts associated with the user's last known IP address. |
user register <name> <password> | librepremium.user.register | Manually registers a new user. |
user login <name> | librepremium.user.login | Forces a login for an online, unauthenticated user. |
user unregister <name> | librepremium.user.unregister | Removes a user's password, 2FA, and session data, effectively unregistering them. |
user delete <name> | librepremium.user.delete | Completely deletes a user's record from the database. |
user migrate <name> <newName> | librepremium.user.migrate | Changes a user's nickname. |
user pass-change <name> <password> | librepremium.user.pass-change | Forcibly changes a user's password. |
user premium <name> | librepremium.user.premium | Forcibly enables premium auto-login for a user. |
user cracked <name> | librepremium.user.cracked | Forcibly disables premium auto-login for a user. |
user 2faoff <name> | librepremium.user.2faoff | Disables 2FA for a user. |
user emailoff <name> | librepremium.user.emailoff | Removes the email address from a user's account. |
user setemail <name> <email> | librepremium.user.setemail | Sets the email address for a user. |
Sources: Plugin/src/main/java/xyz/xreatlabs/nexauth/common/command/commands/staff/NexAuthCommand.java:213-506
Staff User Management Flow
The following diagram shows the typical flow for a staff command that modifies a user, such as /nexauth user delete. It involves checks to ensure the user exists and is offline.