Complete Example Suite
Adapter Methods
| Method | Parameters | Returns | Description |
|---|---|---|---|
createCommandSender | String name | Object | Create a mock command sender with the given name |
grantPermission | Object sender, String permission | void | Grant a permission node to the sender |
revokePermission | Object sender, String permission | void | Remove a permission node from the sender |
hasPermission | Object sender, String permission | boolean | Check if the sender has a permission |
clearPermissions | Object sender | void | Remove all permissions from the sender |
Assertion Methods
| Method | Parameters | Failure Message |
|---|---|---|
assertHasPermission | Object sender, String permission | ”Expected sender to have permission [permission]“ |
assertNoPermission | Object sender, String permission | ”Expected sender to lack permission [permission]“ |
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 viaPermissionsModule.get().
| Method | Description |
|---|---|
hasPermission(UUID, String) | Check if a player has a permission node |
hasPermission(UUID, String, boolean) | Check with a default fallback value |
addUserPermission(UUID, Set<String>) | Grant permissions to a player |
removeUserPermission(UUID, Set<String>) | Revoke permissions from a player |
addGroupPermission(String, Set<String>) | Grant permissions to a group |
removeGroupPermission(String, Set<String>) | Revoke permissions from a group |
addUserToGroup(UUID, String) | Add a player to a permission group |
removeUserFromGroup(UUID, String) | Remove a player from a group |
getGroupsForUser(UUID) | Get all groups a player belongs to |
getProviders() | List all registered permission providers |
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 implementPermissionProvider. The default provider is HytalePermissionsProvider which stores permissions in a JSON file. Has addUserPermissions(), removeUserPermissions(), getUserPermissions(), addGroupPermissions(), removeGroupPermissions(), getGroupPermissions(), addUserToGroup(), removeUserFromGroup(), getGroupsForUser().
Permission Events
PlayerPermissionChangeEventfires when a player’s permissions change. HasgetPlayerUuid().GroupPermissionChangeEventfires when a group’s permissions change. HasgetGroupName().PlayerGroupEventfires when a player is added/removed from a group. HasgetGroupName().
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
clearPermissionsbetween tests if you reuse a sender across multiple assertions to avoid state leaks.