Skip to content

Permissions System

Andrew edited this page Jul 21, 2019 · 7 revisions

CNP Permissions System

ForgePermissionsAPI

The Constitution Mod utilizes ForgePermissionAPI at its core. CNP is registered as the defaultPermissionHandler within the ForgePermissionAPI. Permission Nodes (including those of other mods) are passed through our PermissionProvider class. We recommend Mod Developers to register their permissions through Forge during Pre-Initialization.

Modifying Users/Groups

Setting permission nodes for both users and groups has been made very user friendly.
Users.json and Groups.json are existing files under Minecraft/Config/Constitution/JSON
These files are generated after the first launch of the mod, and read/written actively.

One can set permissions by editing these files directly through text editing software,
OR through in game commands (/cnp group perm add or /cnp user perm add )

REMEMBER: Parent Nodes Must Be Specified For Access To Specific Commands (see below):
While nodes can be set in any order, they must be done through an existing hierarchy:
For Example: Command: /cnp user perm add (This is what the JSON File for either the group/user "Permissions" array must look like)

"Permissions": [
      "constitution",
      "constitution.cmd",
      "constitution.cmd.perm",
      "constitution.cmd.perm.user",
      "constitution.cmd.perm.user.perm",
      "constitution.cmd.perm.user.perm.add"
    ]

Minecraft Vanilla Command Permissions look like this:

"Permissions": [
      "command.help",
      "command.op",
      "command.gamemode",
      "command.time",
    ]

Notice To Other Mod Developers:

CNP was built not to be depended on through conventional means (declaring as a dependency). We have an automated system to register nodes declared in the Groups.json or Users.json files. Meaning, any nodes declared by server owners will be automatically registered during Pre-Init. We respect your project(s) and maintain a no-PR policy (To fix compatibility issues on our own). However, if you wish to do the right thing and comply with Forge follow these instructions:

  1. Create a collection of your permission nodes.
  2. Import net.minecraftforge.server.permissions.PermissionsAPI
  3. Pass your permission nodes through PermissionsAPI.registerNode(String Node) [During PreINIT]
  4. Do not directly reference the PermissionHandler or declare a new one.

Permission Node Documentation:

Documentation for every individual node can be found in their respective wiki pages. Click on one of those pages to view the documentation, if it doesn't exist request it in an issue.