Skip to content

Commit b744765

Browse files
committed
feat: add 'Permission Management' guide
Signed-off-by: ItsNeil17 <neil@willofsteel.me>
1 parent e7afd4a commit b744765

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
title: "Permission Management"
3+
description: "Learn how to manage permission nodes in your Hytale plugin."
4+
authors:
5+
- name: "Neil Revin"
6+
link: "https://itsneil.dev"
7+
- name: "Bird"
8+
link: "https://discord.com/users/495709580068651009"
9+
---
10+
11+
In this guide, you'll learn how to manage permission nodes in your Hytale plugin.
12+
13+
## The `PermissionsModule` class
14+
15+
The `PermissionsModule` class is responsible for managing permission nodes in your plugin. It provides methods to check, grant and revoke permissions for players.
16+
17+
### Adding Permission Nodes
18+
19+
You need a `Set<String>` containing all the permission nodes you want to add, these are added on top of the already existing permission nodes the user may have, it is not a replacement.
20+
21+
```java
22+
Set<String> permissions = new HashSet<>();
23+
PermissionsModule perms = PermissionsModule.get();
24+
perms.addUserPermission(playerUUID, permissions);
25+
```
26+
27+
### Removing Permission Nodes
28+
29+
Same as above, we just use the `removeUserPermission` method instead to remove permission nodes.
30+
31+
```java
32+
Set<String> permissions = new HashSet<>();
33+
PermissionsModule perms = PermissionsModule.get();
34+
perms.removeUserPermission(playerUUID, permissions);
35+
```
36+
37+
### Check Permission Nodes
38+
39+
To check if a player has a specific permission node, you can use the `hasPermission` method.
40+
41+
```java
42+
PermissionsModule perms = PermissionsModule.get();
43+
boolean hasPermission = perms.hasPermission(playerUUID, "permission.node");
44+
```

0 commit comments

Comments
 (0)