auth¶
This page contains tutorials about theauth package.
Naming convention on permissions¶
Permissions should always start with the full name or short name of the pluginthat defines the permission. This avoids name clashes with other plugins. E.g.if your plugin is calledadmin and you want to define the two permissionskick andban, the names of the permissions should beadmin.kickandadmin.ban. This also allows server owners to grant people allpermissions for your plugin by simply usingadmin.*.
Check if a player is granted a permission¶
You can easily check if a player is granted a specific permission by accessingtheplayers.entity.Player.permissions attribute.
fromfilters.playersimportPlayerIter# Loop through all human players and test if the player is granted the# permission 'my_plugin.something'forplayerinPlayerIter('human'):print('"my_plugin.something" is granted to "{}"?:{}'.format(player.name,'my_plugin.something'inplayer.permissions))
Granting a permission¶
By using theplayers.entity.Player.permissions attribute you can alsoeasily grant a player a permission.
fromfilters.playersimportPlayerIter# Loop through all human players and grant the permission 'my_plugin.something'forplayerinPlayerIter('human'):player.permissions.add('my_plugin.something')
Removing a permission¶
Removing a permission is as easy as adding one.
fromfilters.playersimportPlayerIter# Loop through all human players and remove the permission 'my_plugin.something'forplayerinPlayerIter('human'):player.permissions.remove('my_plugin.something')
