Skip to main content
The Permissions surface lets you create mock command senders with configurable permissions and assert on permission state. This is useful for testing command handlers and access control without real player connections. Permission testing catches a common class of security bugs: commands that should be restricted but are not, or commands that deny access when they should not. By verifying permission grants and revocations in automated tests, you ensure that your access control works correctly after every code change.

Complete Example Suite

Adapter Methods

Assertion Methods

Hytale Permissions System API

Beyond mock senders, the Hytale server exposes a full permissions system you can access directly:

PermissionsModule

The server’s permission manager. Access via PermissionsModule.get().

HytalePermissions Constants

Built-in permission node constants: COMMAND_BASE, ASSET_EDITOR, BUILDER_TOOLS_EDITOR, FLY_CAM, and more. Use HytalePermissions.fromCommand(String) to derive a permission node from a command name.

PermissionProvider Interface

Custom permission backends implement PermissionProvider. The default provider is HytalePermissionsProvider which stores permissions in a JSON file. Has addUserPermissions(), removeUserPermissions(), getUserPermissions(), addGroupPermissions(), removeGroupPermissions(), getGroupPermissions(), addUserToGroup(), removeUserFromGroup(), getGroupsForUser().

Permission Events

  • PlayerPermissionChangeEvent fires when a player’s permissions change. Has getPlayerUuid().
  • GroupPermissionChangeEvent fires when a group’s permissions change. Has getGroupName().
  • PlayerGroupEvent fires when a player is added/removed from a group. Has getGroupName().

Key Details

  • Mock command senders start with no permissions - grant what you need explicitly in each test.
  • Permission nodes are string-based and case-sensitive. "MyMod.Admin" and "mymod.admin" are different permissions.
  • Use clearPermissions between tests if you reuse a sender across multiple assertions to avoid state leaks.

Next Steps

  • Commands - test command execution with permissioned senders
  • Players - mock player entities
  • Events - capture permission-related events