How can I check for the presence of a permissions plugin

Discussion in 'Plugin Development' started by marti.2001, Jul 19, 2016.

Thread Status:
Not open for further replies.
  1. Offline

    marti.2001

    I'm making a plugin and I want this: everyone has permission to use a specific command if no permissions plugin is installed, but if it is, then noone has permission to use the command unless they have a permission node.
    Currently, everyone has the permission unless they have a negative node (-myplugin.use). Here's my code:
    plugin.yml (open)

    Code:
    ...
    
    permissions:
      myplugin.use:
        default: true
    
    ...

    Command code (open)

    Code:
    ...
    
    if (!p.hasPermission("styletp.use")) {
            p.sendMessage(noPermission);
            return true;
    }
    
    ...


    How can I make it so that if no permissions plugin is present, then anyone can use the command, but if there is a permissions plugin installed, then players need to have the permission node to use the command?
     
  2. Offline

    CostelabrMn

    You need to install any permission plugin, like pex or group manager. Else you cant set the permissions to any player.
     
  3. Offline

    marti.2001

    @CostelabrMn That's not what I'm trying to say. I'm trying to make the plugin allow any player to run the command if a permissions plugin is not installed, but require the permission node if a permissions plugin is installed.
     
  4. Use JavaPlugin's methods to test if a certain plugin is installed.
     
  5. Offline

    Firestar311

    There is a method that you can use, but you need to know the main class name of the plugin
    Code:java
    1. Bukkit.getServer().getPluginManager().getPlugin("Name");
     
  6. Offline

    marti.2001

    Thanks to everyone, it looks like I'm going to have to find a different way.
     
  7. @marti.2001

    Just a thought, might be completely wrong, but doesn't Vault have a method for this? It seems
    like a vault thing..
     
  8. Offline

    ArsenArsen

    Theres always a permission "plugin". Bukkit has a default permission system.
     
Thread Status:
Not open for further replies.

Share This Page