Get infos from permissions plugin

Discussion in 'Plugin Development' started by ShCr, Jul 1, 2013.

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

    ShCr

    Hi everybody, I'm looking (again, sorry) for help.
    (I remind to you that i'm french, i'm sorry for the grammatical errors ;) )

    I would like to display admin & modos list from any permissions plugin found in the /plugin folder
    (pex, groupmanager and other), with their colors.

    I'm an absolute beginner, any help would be helpfull
    (i don't ask you to write the entire script ^^ )

    Thank you!
     
  2. Offline

    EcMiner

    You could add all the plugins to your workspace and do it for every single one, ore you could use Vault, they already added multiple permission plugins to their library, you could easily acces it from there
     
  3. Offline

    ShCr

    Will peoples have to download vault to run my plugin?
     
  4. Offline

    MCForger

  5. Offline

    EcMiner

    Pleas tag me with EcMiner cause i don't get notified when you don't tag me :)
     
  6. Offline

    ShCr

    Thx EcMiner,

    i think i'll not use vault.
    How should i beggin?
     
  7. Offline

    EcMiner

    ShCr You should download all the permission plugins you want your plugin to be supported and add them to your library
     
  8. Offline

    ShCr

    Thx EcMiner, i'll try it and i'll try to see if i can do something
     
  9. Offline

    MP5K

    Hello ShCr,
    What about using vault? :3
     
  10. Offline

    EcMiner

    I already said that, ShCr decided to not use vault :p
     
  11. Offline

    MP5K

    oops sorry :D
    didn't read that :3
     
  12. Offline

    ShCr

    Exactly, i'm a kind of badass.

    Well, my dear EcMiner (i'm sorry to annoy you), i've put the pex "external jar" in my project to begin, and iv've tried to do stuffs, but i really don't have any idea about how to detect if pex is installed in the /plugin folder, and how to acces to the permissions.yml.

    Thank for helping me, that's nice.
     
  13. Offline

    EcMiner

    You have multiple ways of doing this, but what i find the most simple way is this:
    Code:java
    1. public void checkPermissionsEx() {
    2. Plugin pex = getServer().getPluginManager().getPlugin("PermissionsEx");
    3. if(pex !=null) {
    4. // PermissionsEx is detected and installed correctly
    5. } else {
    6. // PermissionsEx has not been detected
    7. }
    8. }


    you have to run this method inside the onEnable() method, and in the plugin.yml you have to put: softdepend: [PermissionsEx]
     
  14. Offline

    ShCr

    EcMiner

    Thx dude you're awesome.
    I'll try to do shits today.

    [Edit] Well, i've got errors on the "public void checkpermissions".

    Here's my code:

    Show Spoiler
    Code:
        @Override
        public void onEnable ()
        {
            saveDefaultConfig();
            public void checkPermissionsEx()
            {
                Plugin pex = getServer().getPluginManager().getPlugin("PermissionsEx");
                if(pex !=null)
                {
                    //detected.
                }
                else
                {
                    //not detected at all.
                }
            }
            this.getLogger().info("Enabled");
            super.onEnable();
        }
        


    "public void checkpermissionsex"
    - syntax error on token "void", @ expected
    " Plugin pex = getServer().getPluginManager().getPlugin("PermissionsEx")"
    -Illegal modifier for parameter pex; only final is permitted
    -Plugin cannot be resolved to a type
     
  15. Offline

    EcMiner


    You can not put a method inside a method, you have to create it outside the onEnable() method and type this in the onEnable() method: checkPermissionsEx();
     
  16. Offline

    ShCr

    How do i call the checkPermissionsEx() in the onEnable()? :confused:
     
  17. Offline

    GodzOfMadness

    ShCr
    [OFF TOPIC]
    Method Inception :eek:
    [ON TOPIC]
    Just put the method outside of the onEnable() method and then to call it, just type the method name and it's parameters(if any) like so, checkPermissionsEx();
     
  18. Offline

    ShCr

    Show Spoiler
    [CODE:JAVA]
    @Override
    public void onEnable ()
    {
    saveDefaultConfig();
    checkPermissionEx();
    this.getLogger().info("Enabled");
    super.onEnable();
    }

    @Override
    public void onDisable()
    {
    this.getLogger().info("Disabled");
    super.onDisable();
    }

    public void checkPermissionsEx()
    {
    Plugin pex = getServer().getPluginManager().getPlugin("PermissionsEx");
    if(pex !=null)
    {
    //detected.
    }
    else
    {
    //not detected at all.
    }
    }
    [/CODE:JAVA]


    Like that GodzOfMadness?

    I have an error on "checkPermissionEx" in the onEnable method:
    -The method checkPermissionEx is undefined for the type mypluginname
     
  19. Offline

    GodzOfMadness

    ShCr You forgot an 's' in checkPermissionsEx() in your onEnable() method :p
     
  20. Offline

    ShCr

    F*ck, thx!

    I'll try to work with this for the moment, thx guys, really.
     
  21. Offline

    ShCr

    @GodzOfMadness
    EcMiner

    Hi, sorry about the long time (I was busy with setting up my first server :D!).

    Well, i take back the work on my plugin, and i added PermissionsBukkit to my plugin:

    Show Spoiler

    Code:java
    1.  
    2. public void checkPermissionsBukkit()
    3. {
    4. Plugin pb = getServer().getPluginManager().getPlugin("PermissionsBukkit");
    5. if(pb !=null)
    6. {
    7. this.getLogger().info("PermissionsBukkit Found!");
    8. }
    9. else
    10. {
    11. // PermissionsEx has not been detected
    12. }
    13. }
    14.  



    This is in my @override, under the onEnable & onDisable methods (no more method inception! [sheep]).

    What I want to do:
    If in my config.yml "perms" is set to true, the plugin will display a list of the players in the "group"
    If not, the plugin will just diplay the "list".

    Show Spoiler


    config.yml
    Show Spoiler

    Code:
    staff:
     
      #If perms is set to true, the plugin will look for a permissions plugin in your server,
      #and load a list of the members off the group.
      #If perms is set to false, the plugin will display the list below.
     
      perms: true
      group: Admin
     
      list:
    


    My plugin code:
    Show Spoiler

    Code:java
    1. if(sender.hasPermission("si.staff"))
    2. {
    3. if(this.getConfig().getBoolean("staff.perms")==true)
    4. {
    5. sender.sendMessage(getServer().getPluginManager().getPlugin("PermissionsBukkit").getConfig().getString("groups."+this.getConfig().getString("staff.group")));
    6. }
    7. else
    8. {
    9. //send list in the config.yml
    10. }
    11. }
    12. else
    13. {
    14. sender.sendMessage(ChatColor.RED+getConfig().getString("no permissions message"));
    15. }




    I don't know how ,to take the PermissionsBukkit list and display it, and i simply don't know how to take the list in my config.yml. I've tried a lot of things, but it diddn't work...

    Could you please (again) help me?
     
Thread Status:
Not open for further replies.

Share This Page