1.16.x Listen and retrieve permission nodes from other plugins

Discussion in 'Spigot Plugin Development' started by KyTDK, Oct 17, 2020.

  1. I have come across a plugin that is able to listen for permission nodes that other plugins use and give them to the player, luckperms. I want to do the same thing but on a simpler scale. I tried reading the source code but I couldn't find anything. EDIT Just to clarify I want to override permission checks and slowly build a database.
     
    #1 KyTDK, Oct 17, 2020
    Last edited: Oct 17, 2020
  2. if you came across that plugin, then why not use it instead of asking for help here? Don't come on the forums asking for help on how to create an entire plugin.
     
  3. I'm not quite sure what you exactly want to do.

    If you are trying to simply execute some code if a player has a permission from another plugin, it's simple as:
    Code (Text):

    if (player.hasPermission("otherPlugin.node")) {
        //Do something
    }
     
    If you're trying to get a list of all permission nodes in some plugin's plugin.yml, Then you can do that by taking all children of permissions in that plugin's plugin.yml. You can access this pretty easily, but you'll need to make some check the plugin is installed:

    Code (Text):

    if (Bukkit.getPluginManager().getPlugin("otherPlugin") != null) {
        Plugin otherPlugin = Bukkit.getPluginManager().getPlugin("otherPlugin");
        if (Bukkit.getPluginManager().getPlugin("otherPlugin").isEnabled()) {
            List<Permission> otherPluginPermission = plugin.getDescription().getPermissions()
        }
    }
     
    To get ALL other permissions, just do this for all plugins on the server:

    Code (Text):

    Plugin[] plugins = Bukkit.getPluginManager().getPlugins();
    for (Plugin plugin : plugins) {
        //Do permission stuff
    }
     
    Hope this helps.
     
  4. Don't spoonfeed the OP bro
     
  5. There is currently not a permission hook, it would be handy. Why not tell us what your end goal is. There are multiple paths to enlightenment you only have to choose one...
     
  6. I want to override the permission checker so I can retrieve the permission nodes from other plugins when they check for permissions, its like how luckperms shows all the permissions with verbose.