Creating Permissions

In my plugin, I need to check if a player has a permission during an event listener. I understand how to check if the player has the permission but I am not sure how to create the permission. This permission is not tied to a command so I am a bit stumped. I’ve looked through the javadocs but I was unable to find anything that would help me (maybe this isn’t possible in the API at the moment?). I am also curious on when permissions are registered, how it is determined which subjects will have permission or not.
Any help on this is appreciated.

there isn’t a way to really “register” a permission yet; though pretty sure @zml’s working on a permission-registry-thing, issue #548

for now, you don’t create the permission, just check if the player has it.

1 Like

A permission is just a string.

2 Likes

@boformer That doesn’t really answer anything I asked.

There is no need to “register” permissions. Use player.hasPermission(String perm)

4 Likes

Of course, there is a reason to “register” permissions. Not everyone wants to use a permission-plugin made by other devs. So it would be nice if we had an “easy” (or at least easier) way to register permissions to a subject (in this case: the player).
So making your own permissions-plugin would be a lot easier. I know that there is a way with the Permissions-Service (take a look at PEX for Sponge), but I personally think that an easier way of altering permissions would be great…

Huh? I don’t understand what you mean GeMo.

Alter them how?

i think what he’s trying to get at is having the server manage the permissions on its own.

in that case, @GeMo, that’s not a viable reason; Sponge won’t implement permissions on their own because there’re thousands of ways to do it. that’s why we have plugins in the first place instead of just having a server with everything at once.

the registry isn’t for alteration, it’s for information. its for getting the list of permissions that exist on the server as denoted by plugins and attaining any extra information set on them by their owning plugins.