proposal: layered perm system
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
-
Add several
addPerm/removePermmethods that operate on all game mode permission trees simultaneously when called. -
Add a
globalPermTree, with the layered permission trees inheriting from theglobalPermTree.