How to create a plugin using the PEX api?

Discussion in 'Plugin Development' started by Lanuk, Feb 4, 2012.

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

    Lanuk

    So I want to create a plugin that allows a player to rank up by say doing a certain command using PEX. The problem is, how do I access the PEX API so I can make a plugin that does this? Do I need to add any libraries? I am pretty new to this so sorry if I make no sense.
     
  2. Offline

    number1_Master

    i believe you have to add it to your libraries
    do you mean permission nodes?
    for that u just have to do player.hasPermission("permission.node.here");
     
  3. Offline

    Lanuk

    Oh ok, and no, I want to be able to mess with groups. Also, I looked online and wasnt able to find the API to put in my library, any ideas?
     
  4. Offline

    Perdog

    Vault, it allows you too hook into permission plugins that they support, and I think they support PEX. This will also make your plugin more flexible, as it'll hook into other perms if the admin doesn't use PEX
     
  5. Offline

    Lanuk

    Oh hey perdog, long time no see. Thanks, ill look into that

    Alright, so I know this is a silly question, but how do I resource vault so my code understands what a vault is?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 23, 2016
  6. Offline

    Perdog

    On the BukkitDev page for vault, they have a very small tutorial on how to initialize the perm variable that you want. If I can recall I think it's something like

    In your main class:
    Code:
    //create a variable like this
    public Permission perm;
     
     
    //then in your onEnable() put this method, make sure it's called before any listeners that will be using it, or else you'll get an NPE
    setupPerms();
    then somewhere in your main class create the setupPerms() method:
    Code:java
    1. public booloean setupPerms() {
    2. RegisterServiceProvider<Permission> permProvider = this.getServer().getServicesManager.getRegistration(net.milkbowl.vault.permissions.Permissions.class);
    3. if (permProvider != null) {
    4. perm = permProvider.getProvider();
    5. }
    6. return (perm != null);
    7. }
     
  7. Offline

    Lanuk

    Oh ok thanks
     
  8. Offline

    IcyRelic

  9. Offline

    Lanuk

    I tried what you said, perdog, but it gives me an error under "getRegistration(net.milkbowl.vault.permission.Permission.class);"

    Do I need to reference something?
     
  10. Offline

    Roadkill909

    getServer().getServicesManager().getRegistration(net.milkbowl.vault.permission.Permission.class);

    Make sure you use the getServer().getServicesManager() portion
     
  11. Offline

    Perdog

    He does have that part, its just showing an error on the part he posted, likely because he hasn't added vault as an external library
    Like I stated above, you need to add vault as an external library, the same way you added bukkit to it. It would still work on a server
    without having it as an external library, but eclipse wont know what you're trying to reference, and that's why it gives you an error.
     
  12. Offline

    Lanuk

    Ah, I thought so, otherwise how could my code recognize what the hell vault was XD

    So I just drag n drop that vault jar file?

    EDIT: Tried resourcing the Vault.jar, didnt work... what am I supposed to resource o.o

    DOUBLE EDIT: When I resourced me it gave me a different error under that whole line. It says:

    Type mismatch: cannot convert from org.bukkit.plugin.RegisteredServiceProvider<net.milkbowl.vault.permission.Permission> to org.bukkit.plugin.RegisteredServiceProvider<org.bukkit.permissions.Permission>
     
  13. Offline

    Lolmewn

    Sure! Should work ;)
     
  14. Offline

    Perdog

    Nonono :p You know how you added bukkit to your project? By right clicking the project, going to "build path", then "Configure build path". That's what you need to do. Click add external jar file, and select vault.
     
  15. Offline

    Lanuk

    I know, I did that, but it gives me that new error I am now getting :/
     
  16. Offline

    Perdog

    Oh, you imported "Permissions" from bukkit. So go up to your imports and delete the one from bukkit permission, which is the one it can't convert too
     
  17. Offline

    Lanuk

    Ahh, I ALWAYS mess up on my imports! Thanks!
     
Thread Status:
Not open for further replies.

Share This Page