pmmp / PocketMine-MP

A server software for Minecraft: Bedrock Edition in PHP
https://pmmp.io
GNU Lesser General Public License v3.0
3.24k stars 1.52k forks source link

Automatically declare parent permission groups #6324

Open dktapps opened 3 months ago

dktapps commented 3 months ago

Description

Currently, the permission system doesn't make any assumptions about the strings used to identify permissions. However, in practice, permissions typically look like this: pocketmine.command.gamemode.self

However, if trying to set the permission pocketmine.command.gamemode to override all of the sub permissions, nothing will happen.

This issue proposes that . should be considered as a hierarchy separator by the internal system, and parent permission nodes automatically declared to allow users to get the expected behaviour.

This means that registering pocketmine.command.gamemode.self would generate the following hierarchy:

`pocketmine`
-> `pocketmine.command`
  -> `pocketmine.command.gamemode`
    -> `pocketmine.command.gamemode.self`

Alternative methods

dktapps commented 3 months ago

This would also be useful for backwards compatibility purposes. Currently, if we want to divide an existing permission into sub permissions, the original permission declaration has to be explicitly retained, as seen here: https://github.com/pmmp/PocketMine-MP/commit/567bd8abb5dfbd4a035a081663cba820f45887e7#diff-28f7c5edac5d9f0ad9a1eabb7aada678eb60c4d2f8ca5da16a68acad45fb724c

This shouldn't be necessary, as the "deprecated" permission should be auto declared.