PermissionsManager and DefaultPermissionsProvider improvements#425
PermissionsManager and DefaultPermissionsProvider improvements#425OMEGA3065 wants to merge 7 commits into
Conversation
|
I might respond faster if receive a ping in the discord: <@799984967227670529> |
davidsebesta1
left a comment
There was a problem hiding this comment.
Nice work, but needs some changes. Could you please also include link to some testing plugin code?
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
|
@davidsebesta1 Made a simple ish plugin which covers most of the changes. It requires Axwabo's CommandSystem plugin (I am sorry but I am never using the vanilla system again) You can use the commands: Some screenshots: (note I started of with having the rank8 so I can access console) |
davidsebesta1
left a comment
There was a problem hiding this comment.
Much better 👍
Make sure you also add the methods you added to DefaultPermissionProvider to IPermissionsProvider too
| /// An internal bool indicating whether the permission was created at runtime and should not be saved. | ||
| /// </summary> | ||
| [YamlIgnore] | ||
| public bool IsRuntime { get; internal set; } = true; |
There was a problem hiding this comment.
Id make this false by default and add it as optional param to constructor
There was a problem hiding this comment.
If the caller is allowed to do this without the knowledge of what the flag does, they could end up overriding their config files and will be unable to modify the PermissionGroup after it's creation.
If you think this behavior is fine, I can of course change it.
There was a problem hiding this comment.
If the caller is allowed to do this without the knowledge of what the flag does, they could end up overriding their config files and will be unable to modify the PermissionGroup after it's creation. If you think this behavior is fine, I can of course change it.
What I mean by "do this" is change the value of the IsRuntime property.
My intent was not to create a breaking change since anybody who has a custom IPermissionProvider would need to change their code if I added new methods. I could create a new interface with these runtime methods which would prevent the issue as far as I can see. |
15.0 will have major breaking changes and we do not have any more updates planned before that. You are good to make these changes |
I found another reason against this change. I currently have a custom IPermissionProvider which doesn't use PermissionGroups in any capacity. All of the new methods do in fact use PermissionGroups and as such would not fit in very well. Again I could maybe make another interface with these methods, but I am not sure how useful this would be. |



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>usingActivator.CreateInstanceeven though the type argument was specified as supporting a parameterless constructor. Modified code so instead of usingActivator.CreateInstance<T>()it usesnew T().GetProvider(Type type)which allows to get a provider even if we only have it's type object (runtime) as provided byGetPermissionsByProviderTryGetProvider<T>(out provider) -> Twhich 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>usingActivator.CreateInstanceeven though the type argument was specified as supporting a parameterless constructor. Modified code so instead of usingActivator.CreateInstance<T>()it usesnew T().GetProvider(Type type)which allows to get a provider even if we only have it's type object (runtime) as provided byGetPermissionsByProviderTryGetProvider<T>(out provider) -> Twhich allows the caller to automatically have the returned type be the type provided as an argument.GetPlayerGroupwas made publicGetPermissionGroupwas added to allow the caller obtain thePermissionGroupbased on a string UserGroup registry name.GetPermissionswas made publicAddPermissionGroupwas added to allow the caller to add / override existing groups.RemovePermissionGroupsame reason as AddPermissionGroup` but for removal of groups.