Giving permissions without implementing Permissions Service

Hello guys,

I’d love to do something, but I don’t know if it is possible. So i’ll just ask the question, and if it’s not possible then let’s forget about that :stuck_out_tongue:

Is it possible for a plugin, without implementing the permissions api (which means using the default implementation based on OP/not OP), to simply give some permissions to players that are not OP ?

Sorry if this is a dumb question :disappointed_relieved:

1 Like

See my answer here:

1 Like

Oh I see, thanks !

I quite don’t get the concept of context for permissions… Is it something that allows plugins to give/take permissions in specific cases ? Well in my case I’ll provide an empty Set to be in the global context but it’s always a good thing to know.

Yes, I believe so. For example, I believe you can use contexts to give permissions depending on the world a player is in.

1 Like

Ok thanks again !

I don’t even think you need to go that far…

IF you correctly register your PermissionDescriptions with the correct Roles I believe the default PermissionsService in sponge will grant users the correct permissions?

@ryantheleach I hoped so, but last time I used that, it’s not granted or did anything, except for storing that for purely informational purposes.
I’m also stumped, how to make plugin functional for regular users with “no Perm plugin installed” environment (aka ‘graceful fallback’).

Will it override already existing permissions if Perm plugin is installed?

I honestly don’t think that should be something that plugins should need to worry about… I’d be interested in hearing the sponge implementation developers thoughts about it.

I quite don’t get what PermissionDescriptions are and more precisely how to set them up

Has anyone a link where it’s explained or a brief explanation to give here ?

If it’s indeed a way to suggest the permissions service what permission should be given to what players in a more conventional way, then I’d rather do that.

The JavaDocs for this are near perfect.

Hmm ok I begin to understand. So for example, if I have a command with a myplugin.command.myprettycmd permission that all users should be able to perform, that should be it right ?

Optional<Builder> optDescriptionBuilder = permissionService.newDescriptionBuilder(this); // in my main plugin class
if (optDescriptionBuilder.isPresent())
{
    optDescriptionBuilder.get()
    .id("myplugin.command.myprettycmd")
    .description(Text.of("My pretty description"))
    .assign(PermissionDescription.ROLE_USER, true)
    .register();
}

Yup!

And then whatever ends up implementing the Permissions service can either assign your new permission to new users, or merely use it to tell end users what permissions your plugin has to use in an easy GUI.

1 Like

I see. Thanks a lot !