Skip to content

Commit 036e46a

Browse files
committed
Document permissions
1 parent a89088a commit 036e46a

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

api/src/main/java/com/lishid/openinv/util/Permissions.java

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,38 +27,86 @@
2727
*/
2828
public enum Permissions {
2929

30+
/// Permission to open one's own inventory.
3031
INVENTORY_OPEN_SELF("inventory.open.self"),
32+
/// Permission to open someone else's inventory.
3133
INVENTORY_OPEN_OTHER("inventory.open.other"),
34+
/**
35+
* Permission to edit one's own inventory.
36+
*
37+
* <p>Note that this does not guarantee that the user has access to open the inventory!
38+
* Be sure to check {@link #INVENTORY_OPEN_SELF} first.</p>
39+
*/
3240
INVENTORY_EDIT_SELF("inventory.edit.self"),
41+
/**
42+
* Permission to edit someone else's inventory.
43+
*
44+
* <p>Note that this does not guarantee that the user has access to open the inventory!
45+
* Be sure to check {@link #INVENTORY_OPEN_OTHER} first.</p>
46+
*/
3347
INVENTORY_EDIT_OTHER("inventory.edit.other"),
48+
/// Permission to insert any item into the head slot.
3449
INVENTORY_SLOT_HEAD_ANY("inventory.slot.head.any"),
50+
/// Permission to insert any item into the chest slot.
3551
INVENTORY_SLOT_CHEST_ANY("inventory.slot.chest.any"),
52+
/// Permission to insert any item into the legs slot.
3653
INVENTORY_SLOT_LEGS_ANY("inventory.slot.legs.any"),
54+
/// Permission to insert any item into the feet slot.
3755
INVENTORY_SLOT_FEET_ANY("inventory.slot.feet.any"),
56+
/// Permission to drop items as the player via the drop slot.
3857
INVENTORY_SLOT_DROP("inventory.slot.drop"),
3958

59+
/// Permission to open one's own ender chest.
4060
ENDERCHEST_OPEN_SELF("enderchest.open.self"),
61+
/// Permission to open someone else's ender chest.
4162
ENDERCHEST_OPEN_OTHER("enderchest.open.other"),
63+
/**
64+
* Permission to edit one's own ender chest.
65+
*
66+
* <p>Note that this does not guarantee that the user has access to open the inventory!
67+
* Be sure to check {@link #ENDERCHEST_OPEN_SELF} first.</p>
68+
*/
4269
ENDERCHEST_EDIT_SELF("enderchest.edit.self"),
70+
/**
71+
* Permission to edit someone else's ender chest.
72+
*
73+
* <p>Note that this does not guarantee that the user has access to open the inventory!
74+
* Be sure to check {@link #ENDERCHEST_OPEN_OTHER} first.</p>
75+
*/
4376
ENDERCHEST_EDIT_OTHER("enderchest.edit.other"),
4477

78+
/// Permission to clear one's own inventory.
4579
CLEAR_SELF("clear.self"),
80+
/// Permission to clear someone else's inventory.
4681
CLEAR_OTHER("clear.other"),
4782

83+
/// Permission to view inventories and ender chests from other worlds.
4884
ACCESS_CROSSWORLD("access.crossworld"),
85+
/// Permission to access offline players' inventories and ender chests.
4986
ACCESS_OFFLINE("access.offline"),
87+
/// Permission to access online players' inventories and ender chests.
5088
ACCESS_ONLINE("access.online"),
89+
/// Permission granting the ability to edit players with the same access level.
5190
ACCESS_EQUAL_EDIT("access.equal.edit"),
91+
/// Permission to view, but not edit, players with the same access level.
5292
ACCESS_EQUAL_VIEW("access.equal.view"),
93+
/// Permission to deny access to players with the same access level.
5394
ACCESS_EQUAL_DENY("access.equal.deny"),
5495

96+
/// Permission to perform inventory interaction while in spectator mode.
5597
SPECTATE_CLICK("spectate.click"),
5698

99+
/// Permission to use the AnyContainer feature.
57100
CONTAINER_ANY("container.any"),
101+
/// Permission to use the AnyContainer feature but not the command to toggle it.
58102
CONTAINER_ANY_USE("container.any.use"),
103+
/// Permission to use the SilentContainer feature.
59104
CONTAINER_SILENT("container.silent"),
105+
/// Permission to use the SilentContainer feature but not the command to toggle it.
60106
CONTAINER_SILENT_USE("container.silent.use"),
107+
/// Permission to search inventories and ender chests.
61108
SEARCH_INVENTORY("search.inventory"),
109+
/// Permission to search containers.
62110
SEARCH_CONTAINER("search.container");
63111

64112
private final String permission;
@@ -67,6 +115,12 @@ public enum Permissions {
67115
this.permission = "openinv." + permission;
68116
}
69117

118+
/**
119+
* Check if a {@link Permissible} has this permission.
120+
*
121+
* @param permissible the Permissible
122+
* @return true if the permission is granted
123+
*/
70124
public boolean hasPermission(@NotNull Permissible permissible) {
71125
return permissible.hasPermission(permission);
72126
}

0 commit comments

Comments
 (0)