|
| 1 | +> ## Documentation for basically using PermissionsAPI. |
| 2 | +
|
| 3 | +## 1. For playing and running minecraft: |
| 4 | + |
| 5 | +#### 1.1 Download Permissions API mod module. |
| 6 | + |
| 7 | +Visit **Permissions API** repository on github, visit **releases** tab and download `.jar` files of latest _pre-release_ / release (**recommended**) |
| 8 | + |
| 9 | +Releases page: https://github.com/ProjectEssentials/ProjectEssentials-Permissions/releases |
| 10 | + |
| 11 | +#### 1.2 Install Permissions API modification. |
| 12 | + |
| 13 | +The minecraft forge folder structure below will help you understand what is written below. |
| 14 | + |
| 15 | +``` |
| 16 | +. |
| 17 | +├── assets |
| 18 | +├── config |
| 19 | +├── libraries |
| 20 | +├── mods (that's how it should be) |
| 21 | +│ ├── Permissions-1.14.4-X.X.X.X.jar |
| 22 | +│ └── Your mod with needed dependencies. |
| 23 | +└── ... |
| 24 | +``` |
| 25 | + |
| 26 | +Place your mods and Permissions API mods according to the structure above. |
| 27 | + |
| 28 | +**Important note**: your modification must include the `Kotlin` library, the `Kotlinx Serialization` library, this must be done if you use the Permissions API separately from the main Project Essentials module. |
| 29 | + |
| 30 | +How to include dependencies in the assembly using Gradle is described later in the documentation. |
| 31 | + |
| 32 | +#### 1.3 Verifying mod on the correct installation. |
| 33 | + |
| 34 | +Run the game, check the number of mods, if the list of mods contains `Project Essentials Permissions` mod, then the mod has successfully passed the initialization of the modification. |
| 35 | + |
| 36 | +After that, go into a single world, then try to write the `/essentials permissions` command, if you **get an error** that you do not have permissions, then the modification works as it should. |
| 37 | + |
| 38 | +#### 1.4 Control permissions via minecraft commands. |
| 39 | + |
| 40 | +We understand that there are lazy people who do not like to dig into files (lol, although it’s easier through a file), we made the commands for you: |
| 41 | + |
| 42 | +``` |
| 43 | +/essentials permissions |
| 44 | +
|
| 45 | +- description: base command of permissions api module; just send you about message. |
| 46 | +
|
| 47 | +- permission: ess.perm |
| 48 | +``` |
| 49 | + |
| 50 | +``` |
| 51 | +/essentials permissions save |
| 52 | +
|
| 53 | +- description: save permission configuration. |
| 54 | +
|
| 55 | +- permission: ess.perm.save |
| 56 | +``` |
| 57 | + |
| 58 | +``` |
| 59 | +/essentials permissions reload |
| 60 | +
|
| 61 | +- description: reload permission configuration !!!without saving. |
| 62 | +
|
| 63 | +- permission: ess.perm.reload |
| 64 | +``` |
| 65 | + |
| 66 | +``` |
| 67 | +/essentials permissions group <name> [set | remove] <node> |
| 68 | +
|
| 69 | +- description: remove or set permission for target group. |
| 70 | +
|
| 71 | +- permission: ess.perm.group |
| 72 | +``` |
| 73 | + |
| 74 | +``` |
| 75 | +/essentials permissions user <name> [set | remove] <node> |
| 76 | +
|
| 77 | +OR |
| 78 | +
|
| 79 | +/essentials permissions user <name> set <group name> |
| 80 | +
|
| 81 | +- description: remove or set user permission node, or only set group for user. |
| 82 | +
|
| 83 | +- permission: ess.perm.user |
| 84 | +``` |
| 85 | + |
| 86 | +## 2. For developing and developers: |
| 87 | + |
| 88 | +### 2.1 Getting started with installing. |
| 89 | + |
| 90 | +To get the Permissions API source for development and interactions with the rights of players, you need to get the dependencies and get the documentation to view it in your IDE. |
| 91 | + |
| 92 | +Installation documentation is located in the readme file or just follow the link: https://github.com/ProjectEssentials/ProjectEssentials-Permissions#-install-using-gradle |
| 93 | + |
| 94 | +### 2.2 Configuration. |
| 95 | + |
| 96 | +Like many modifications, the Permissions API has its own modification; it stores groups of players, players, and other necessary data related to rights. The configuration is in `json` format, which is convenient for reading and understanding even the **most stupid person**. |
| 97 | + |
| 98 | +#### 2.2.1 Configuration file Location. |
| 99 | + |
| 100 | +Due to the different file structure on the server and the client of the minecraft, technically we must use different paths for the two sides. |
| 101 | + |
| 102 | +The differences in the paths are primarily due to the different locations of the kernel of minecraft version, but for the average person, the paths will be exactly the same, i.e. like that. |
| 103 | + |
| 104 | + server: ./config/ProjectEssentials/permissions.json |
| 105 | + client: ./config/ProjectEssentials/permissions.json |
| 106 | + |
| 107 | +#### 2.2.2 Configuration file structure. |
| 108 | + |
| 109 | +##### 2.2.2.1 `groups` configuration section. |
| 110 | + |
| 111 | +`groups` contains an array of groups, each element of the array (group) must have the `name`, `isDefault` and `permissions` properties, if there is no property, the default value will be used, but I strongly recommend writing all the properties to manual. |
| 112 | + |
| 113 | +`name` is the name of the group; it should preferably not contain any characters other than letters; **This property must be required**. |
| 114 | + |
| 115 | +`isDefault` only accepts a boolean value; if false, the group will not be set by default; if true, the group will be used as the default; **Note:** at least one group must be with the value `true`, if this is not so, I do not know what will happen, **I did not check**. |
| 116 | + |
| 117 | +`permissions` is a string array, it just records the rights for a specific group. If you are not familiar with `json`, I strongly recommend that you see what it is. **Note:** if the `permissions` array has `"*"`, then this is equivalent to the **operator’s permissions or just gives all the permissions** that the PermissionsAPI controls. |
| 118 | + |
| 119 | +##### 2.2.2.2 `users` configuration section. |
| 120 | + |
| 121 | +`users` contains an array of users, each element of the array (user) must have the `nickname`, `group` and `permissions` properties, if there is no property, the default value will be used, but I strongly recommend writing all the properties to manual. |
| 122 | + |
| 123 | +`nickname` is the nickname of the player; it should preferably not contain any characters other than letters; **This property must be required**. |
| 124 | + |
| 125 | +`group` is the name of the group in which the player is entitled. |
| 126 | + |
| 127 | +`permissions` is a list of rights that belong to a specific player, they can serve as a finer setting of rights; **Note:** if the player has a group, then the rights that are written by the player will be added to the rights that he received from the group. **In short: these are just additional rights for the player.** |
| 128 | + |
| 129 | +##### 2.2.2.3 Just in case. |
| 130 | + |
| 131 | +If something goes according to the cunt, and your configuration flies, just delete the configuration or take the default configuration from here. |
| 132 | + |
| 133 | +**Default configuration**: |
| 134 | + |
| 135 | +```json |
| 136 | +{ |
| 137 | + "groups": [ |
| 138 | + { |
| 139 | + "name": "default", |
| 140 | + "isDefault": true, |
| 141 | + "permissions": [] |
| 142 | + }, |
| 143 | + { |
| 144 | + "name": "owner", |
| 145 | + "isDefault": false, |
| 146 | + "permissions": ["*"] |
| 147 | + } |
| 148 | + ], |
| 149 | + "users": [ |
| 150 | + { |
| 151 | + "nickname": "*", |
| 152 | + "group": "default", |
| 153 | + "permissions": [] |
| 154 | + } |
| 155 | + ] |
| 156 | +} |
| 157 | +``` |
| 158 | + |
| 159 | +### 2.3 API usage. |
| 160 | + |
| 161 | +I could not write this damn documentation at all and spend time on it, because it is so fucking understandable. But just in case, I will nevertheless sign here some trifles. |
| 162 | + |
| 163 | +Let's start small? |
| 164 | + |
| 165 | +#### 2.3.1 Functions. |
| 166 | + |
| 167 | +``` |
| 168 | +PermissionsAPI.hasPermission |
| 169 | +
|
| 170 | +- accepts: |
| 171 | + - playerNickName - nickname of target player. (string) |
| 172 | + - node - permission node as string, e.g ess.weather (string) |
| 173 | + - isServerSender - needed for additional checking permissions. ((boolean) by default is false) |
| 174 | +
|
| 175 | +- return: true if user have permission, else return false. (boolean) |
| 176 | +``` |
| 177 | + |
| 178 | +``` |
| 179 | +PermissionsAPI.getAllUserPermissions |
| 180 | +
|
| 181 | +- accepts: |
| 182 | + - playerNickName - nickname of target player. (string) |
| 183 | +
|
| 184 | +- return: list with all able user and group for user permissions. (list with string type) |
| 185 | +``` |
| 186 | + |
| 187 | +``` |
| 188 | +PermissionsAPI.getDefaultGroup |
| 189 | +
|
| 190 | +- description: NOTE: if default group not exist then return group without permissions and without name. |
| 191 | +
|
| 192 | +- return: default group in what defined configuration file. (Group class instance) |
| 193 | +``` |
| 194 | + |
| 195 | +``` |
| 196 | +PermissionsAPI.getGroupPermissions |
| 197 | +
|
| 198 | +- accepts: |
| 199 | + - groupName - just group name. (string) |
| 200 | + OR |
| 201 | + - groupInstance - just group class instance. (Group class instance) |
| 202 | +
|
| 203 | +- return: list with all able group permissions. (list with string type) |
| 204 | +``` |
| 205 | + |
| 206 | +``` |
| 207 | +PermissionsAPI.getUserGroup |
| 208 | +
|
| 209 | +- accepts: |
| 210 | + - playerNickName - nickname of target player. (string) |
| 211 | +
|
| 212 | +- return: instance of the class of the rights group the user belongs to. (Group class instance) |
| 213 | +``` |
| 214 | + |
| 215 | +``` |
| 216 | +PermissionsAPI.getUserPermissions |
| 217 | +
|
| 218 | +- accepts: |
| 219 | + - playerNickName - nickname of target player. (string) |
| 220 | +
|
| 221 | +- return: list with all able user permissions. (list with string type) |
| 222 | +``` |
| 223 | + |
| 224 | +``` |
| 225 | +PermissionsAPI.removeGroupPermission |
| 226 | +
|
| 227 | +- description: Remove permission node from group. |
| 228 | +
|
| 229 | +- accepts: |
| 230 | + - groupName - just group name. (string) |
| 231 | + - node - group permission. (string) |
| 232 | + OR |
| 233 | + - groupInstance - just group class instance. (Group class instance) |
| 234 | + - node - group permission. (string) |
| 235 | +``` |
| 236 | + |
| 237 | +``` |
| 238 | +PermissionsAPI.removeUserPermission |
| 239 | +
|
| 240 | +- description: Remove permission node from user. |
| 241 | +
|
| 242 | +- accepts: |
| 243 | + - playerNickName - nickname of target player. (string) |
| 244 | + node - user permission. setting up for "*" (any) player. (string) |
| 245 | +``` |
| 246 | + |
| 247 | +``` |
| 248 | +PermissionsAPI.setGroupPermissionNode |
| 249 | +
|
| 250 | +- description: Install \ Add new permission for group. |
| 251 | +
|
| 252 | +- accepts: |
| 253 | + - groupName - just group name. (string) |
| 254 | + - node - new group permission. (string) |
| 255 | + OR |
| 256 | + - groupInstance - just group class instance. (Group class instance) |
| 257 | + - node - new group permission. (string) |
| 258 | +``` |
| 259 | + |
| 260 | +``` |
| 261 | +PermissionsAPI.setUserPermissionGroup |
| 262 | +
|
| 263 | +- description: Install \ Set new permission group for user. |
| 264 | +
|
| 265 | +- accepts: |
| 266 | + - playerNickName - nickname of target player. (string) |
| 267 | + - groupName - new user permission group. (string) |
| 268 | + OR |
| 269 | + - playerNickName - nickname of target player. (string) |
| 270 | + - groupInstance - new user permission group. (Group class instance) |
| 271 | +``` |
| 272 | + |
| 273 | +``` |
| 274 | +PermissionsAPI.setUserPermissionNode |
| 275 | +
|
| 276 | +- description: Install \ Add new permission for user. |
| 277 | +
|
| 278 | +- accepts: |
| 279 | + - playerNickName - nickname of target player. (string) |
| 280 | + - node - new user permission. setting up for "*" (any) player. (string) |
| 281 | +``` |
| 282 | + |
| 283 | +## These are all API methods, I think you understand that everything is very simple. |
| 284 | + |
| 285 | +### For all questions, be sure to write issues! |
0 commit comments