Skip to content

PermissionsManager and DefaultPermissionsProvider improvements#425

Open
OMEGA3065 wants to merge 7 commits into
northwood-studios:masterfrom
OMEGA3065:master
Open

PermissionsManager and DefaultPermissionsProvider improvements#425
OMEGA3065 wants to merge 7 commits into
northwood-studios:masterfrom
OMEGA3065:master

Conversation

@OMEGA3065

Copy link
Copy Markdown
Contributor

Provides new methods which can be used to interact with the PermissionManager and DefaultPermissionsProvider in more ways without the need for publicizing the assembly.

This PR was made because of a suggestion: #424

The changes made to the PermissionManager are mostly QoL with 1 exception.
List of changes:

  • RegisterProvider<T> using Activator.CreateInstance even though the type argument was specified as supporting a parameterless constructor. Modified code so instead of using Activator.CreateInstance<T>() it uses new T().
  • GetProvider(Type type) which allows to get a provider even if we only have it's type object (runtime) as provided by GetPermissionsByProvider
  • TryGetProvider<T>(out provider) -> T which allows the caller to automatically have the returned type be the type provided as an argument.

The changes made to the DefaultPermissionsProvider allow for more interaction concerning obtainging full lists of permissions provided by a UserGroup and allowing for runtime registration of .
List of changes:

  • RegisterProvider<T> using Activator.CreateInstance even though the type argument was specified as supporting a parameterless constructor. Modified code so instead of using Activator.CreateInstance<T>() it uses new T().
  • GetProvider(Type type) which allows to get a provider even if we only have it's type object (runtime) as provided by GetPermissionsByProvider
  • TryGetProvider<T>(out provider) -> T which allows the caller to automatically have the returned type be the type provided as an argument.
  • GetPlayerGroup was made public
  • GetPermissionGroup was added to allow the caller obtain the PermissionGroup based on a string UserGroup registry name.
  • GetPermissions was made public
  • AddPermissionGroup was added to allow the caller to add / override existing groups.
  • RemovePermissionGroup same reason as AddPermissionGroup` but for removal of groups.

@OMEGA3065

Copy link
Copy Markdown
Contributor Author

I might respond faster if receive a ping in the discord: <@799984967227670529>

@davidsebesta1 davidsebesta1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, but needs some changes. Could you please also include link to some testing plugin code?

Comment thread LabApi/Features/Permissions/Providers/DefaultPermissionsProvider.cs Outdated
Comment thread LabApi/Features/Permissions/Providers/DefaultPermissionsProvider.cs Outdated
Comment thread LabApi/Features/Permissions/Providers/DefaultPermissionsProvider.cs Outdated
Comment thread LabApi/Features/Permissions/Providers/DefaultPermissionsProvider.cs Outdated
Comment thread LabApi/Features/Permissions/Providers/DefaultPermissionsProvider.cs Outdated
Comment thread LabApi/Features/Permissions/Providers/PermissionGroup.cs Outdated
OMEGA3065 and others added 3 commits July 4, 2026 11:42
say array instead of just []

Co-authored-by: David <david.sebesta@post.cz>
Co-authored-by: David <david.sebesta@post.cz>
…n the target isn't a runtime group + wording changes
@OMEGA3065 OMEGA3065 requested a review from davidsebesta1 July 4, 2026 10:13
@OMEGA3065

Copy link
Copy Markdown
Contributor Author

@davidsebesta1 Made a simple ish plugin which covers most of the changes.
https://github.com/OMEGA3065/PermissionTest

It requires Axwabo's CommandSystem plugin (I am sorry but I am never using the vanilla system again)

You can use the commands:
ggp - lists perms of a group supplied as arg
gmg - combines roles into 1 multirole to provide all perms of the subroles (uses inheritance)
rmg - removes your custom group -> note this only removes the default provider group and not your actual UserGroup
apmg - adds permissions to a specified permission group, pretty sure labapi has this somewhere built-in but it's whatever
cperms - lists all your permissions for each permission provider you have, good for checking what perms you have on the DefaultPermissionProvider

Some screenshots: (note I started of with having the rank8 so I can access console)
obrázok
obrázok
obrázok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants