Allay icon indicating copy to clipboard operation
Allay copied to clipboard

proposal: layered perm system

Open smartcmd opened this issue 1 year ago • 0 comments

Layered Permission System

In the current permission system of Allay, each player only holds one permission tree. When switching modes, we need to frequently set some permissions, such as BUILD, MINE, ATTACK-PLAYERS, ATTACK-MOBS, etc.

Assume the plugin has a requirement that players can only place blocks but not destroy blocks in survival mode. Thus, the plugin removes the player's MINE permission. However, if the player switches to adventure mode and then back to survival mode, the player's MINE permission is restored.

The original version has a concept called layered permissions, meaning that each game mode has a corresponding permission tree.

When switching modes, you only need to switch to the permission tree of the corresponding mode. When setting permissions, you need to specify which game mode's permission tree is being set.

Perhaps we can learn from this?

Advantages

As mentioned above, the plugin does not need to reset permissions every time the game mode changes. This will make writing the plugin easier and have some potential benefits.

Disadvantages

Not all permissions need to be layered, such as command/chat permissions.

Possible Improvements

  1. Add several addPerm/removePerm methods that operate on all game mode permission trees simultaneously when called.

  2. Add a globalPermTree, with the layered permission trees inheriting from the globalPermTree.

smartcmd avatar Jan 06 '24 17:01 smartcmd