How to add permissions?

i know how to add permission to a command
What im asking is to register a permission that i can check for the player
For example:

i wanna send a message to players who has somepermission.messageget true

You can do that with the UserCollection from the PermissionService. Use the function getAllWithPermission.

1 Like

Player#hasPermission(String)

1 Like

Actually i couldnt understand what are u trying to say :neutral_face:
PermissionService has subjects user group etc. and getAllWithPermission.? where will i use this…
My english is not that good pls explain it simply and with simple examples like;
PermissionService.Subject_User.Something.permission(“permString”).build()

Edit: I’m sorry it’s my fault…

Oh i understand getAllWithPermission now…
And actually its so usefull :slight_smile:

Finally…
My problem is im looking to java as it is VBA…
in VBA or related languages, if u dont register something as its class it doesnt understand u…
But in java i just made a check line for this permission, and it is automatically added to permission list…

Some times i love u java… (But only sometimes…)

If you just want to check if a player has a permission, you can use player.hasPermission("some.permission").

thank you :slight_smile:
actually i knew that but i thought there was a command to add permissions to a permission list but i understood that Sponge does it automatically…

Yes. You can make it even simpler if you want by using CommandSpec.permission("some.permission"), which does the if test automatically and hides the command in /help for players that don’t have permission.

1 Like

I know that what you said was an example, and that you likely want to do other things to a group of people with a permission.
But for the very specific instance of sending a message to everyone with a permission there is a very specific answer :slight_smile:

Lets you literally get a message channel, for sending messages, to people with a permission.

2 Likes