How do I hook into vault?

Discussion in 'Plugin Development' started by calebbfmv, Jul 26, 2012.

?

Have you ever hooked into Vault?

  1. Heck Yes you idiot! Why else would I be here?

    32.1%
  2. No, but I would like to know so I cam here!

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

    calebbfmv

    I don't really understand the one of vaults page, so I was wondering if anyone of you know how to hook into vault? Or rather any permission system, this is for my first plugin that I will release so I wanna get it right.
     
  2. Offline

    r0306

    calebbfmv
    I don't really know what Vault does exactly and I don't like plugin dependencies either because that means a loss of convenience. It's a pain to be forced to install a plugin that relies on another plugin that relies on another plugin that relies on another plugin when you only need the functionality of that one plugin and you want to set up the server really fast.
     
  3. Offline

    raGan.

  4. Offline

    calebbfmv

    Well, this plugin lists all Admins in a group, thus the need to hook into Vault

    Maybe you didn't understand me? But this doesn't really solve my problem...

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

    raGan.

    He does use permission system in that code. Isn't that what you need ?
     
  6. Offline

    calebbfmv

    I'm sorry, I didn't read it all the way through, this might work! Now if only there was a way to make it read all the people online in a certain group....
     
  7. Offline

    raGan.

    Most IDEs will show you all available methods. Methods are named conveniently, so I'm sure you will find a way.
     
  8. Offline

    calebbfmv

    I still can't....
     
  9. Offline

    pzxc

    You need to import Vault.jar into your project just like you imported the bukkit jar into it
    Then you can add the functions they suggest - setupEcon(), setupPermissions(), etc - and call them in your onEnable
     
  10. Offline

    calebbfmv

    I did, but I still cannot get this to work!!!!!!!!!!!!!! :mad:
     
  11. Offline

    pzxc

    What part is it failing at? You have to be more specific. Is it causing a NPE or other error. Does it show you the methods in your IDE for the econ / perms variables you've created. Have you tried adding debug messages to see how far it's getting correctly before it gets to a part where it fails.
     
  12. Offline

    calebbfmv

    OK so, I need to make a plugin that lists all Admins online right? But I cannot seem to no matter how hard I try, I want to make it, i don't want someone to make it for me. But I cannot seem to!!! I get an echo or I get nothing!
    I have a blank page it front of me waiting to be coded on with the magic words, and they keep losing all their mana.
     
  13. Offline

    pzxc

    1. Import the Vault jar into your project, the same way the bukkit jar is imported
    2. Verify that in your onEnable you can type something like "Player p; p." and when you hit the period it brings up a list of methods/variables that the Player object can have
    3. Verify that in your onEnable you can type something like "Economy e; e." and when you hit the period it brings up a list of methods/variables that the Economy object can have
    4. If it doesn't or there are underlines in your IDE you may be missing the vault imports at the top of your code:

    import net.milkbowl.vault.economy.Economy;
    import net.milkbowl.vault.permission.Permission;
    5. Make a couple global variables, inside your class but outside any function like onEnable... public static Economy econ = null; public static Permission perms = null;
    6. In your onEnable initialize them: if (!setupEconomy()) { ... log severe message... } setupPermissions();
    7. You can get the code for how to initialize, along with the setupEconomy and setupPermissions functions, from the Vault website
    8. Try to use the perms object like make a test command that does player.sendMessage(perms.playerHas(player, "my.permission")) give yourself the permission and see if it can read it properly
    9. If vault is working properly, expand upon it by using perms.playerInGroup() to do what you're actually trying to do from the start
     
  14. Offline

    calebbfmv

    I still get errors underneath !setupEconomy/Permission/chat

    package com.example.plugin;

    import java.util.logging.Level;
    import java.util.logging.Logger;

    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.plugin.java.JavaPlugin;

    import net.milkbowl.vault.chat.Chat;
    import net.milkbowl.vault.economy.Economy;
    import net.milkbowl.vault.permission.Permission;

    public class ExamplePlugin extends JavaPlugin {

    public Logger log = Logger.getLogger("Minecraft");
    public static Economy econ = null;
    public static Permission perms = null;
    public static Chat chat = null;

    @Override
    public void onDisable() {
    log.info(String.format("[%s] Disabled Version %s", getDescription().getName(), getDescription().getVersion()));
    }

    @Override
    public void onEnable() {
    if (!setupEconomy() ) {
    log.info(String.format("[%s] - Disabled due to no Vault dependency found!", getDescription().getName()));
    getServer().getPluginManager().disablePlugin(this);
    return;
    }
    setupPermission();
    setupChat();
    }

    Yes I have imported Vault

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

    pzxc

    What is the error message you are getting?
     
  16. Offline

    raGan.

    If this is your whole class, you definitely need to add whole setupPermission methid first to be able to use it. You can't just toss setupPermission(); into your class code. Also you need to get Vault under your referenced libraries. If you did all these things, there is no way to get error.
    And without providing more info about your error, it is very hard to help you.
     
  17. Offline

    calebbfmv

    Well somehow I do get an error, I don't know why
    I am taking the code straight out of Vault's github, ADDED Vault as an external Jar, still get errors.

    I f***ing hate my life! I figured it out.

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

    raGan.

    And solution ? It would be great if you posted it. Was it package or something like that ?
     
  19. Offline

    calebbfmv

    EDIT got that worked out, testing the plugin now

    Plugin.yml is wrong....

    name: Test
    main: com.example.plugin.ExamplePlugin
    version: 0.1
    description: >
    Better lister. Do /Admin to see all online admins.
    commands:
    Admin:
    description: Admin

    Package is com.example.plugin
    class is ExamplePlugin

    13:48:30 [SEVERE] Could not load 'plugins\LetsSee.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: java.lang.ClassNotFoundException: com.
    example.plugin
    at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j
    ava:151)
    at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.
    java:305)
    at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager
    .java:230)
    at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:213)
    at org.bukkit.craftbukkit.CraftServer.<init>(CraftServer.java:189)
    at net.minecraft.server.ServerConfigurationManager.<init>(ServerConfigur
    ationManager.java:53)
    at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:166)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:432)
    at net.minecraft.server.ThreadServerApplication.run(SourceFile:492)
    Caused by: java.lang.ClassNotFoundException: com.example.plugin
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.
    java:41)
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.
    java:29)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j
    ava:140)
    ... 8 more

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

    raGan.

    Is this new problem or old one ? In this case, class is wrong in plugin.yml or is obfuscated.
     
  21. Offline

    calebbfmv

    Same one i have been getting class is ok I think I posted the plugin.yml but I don't know whats wrong here
     
  22. Offline

    raGan.

    if this is in your plugin.yml: com.example.plugin.ExamplePlugin
    you need to be able to find exactly this class in your exported jar: com/example/plugin/ExamplePlugin.class
     
  23. Offline

    calebbfmv

    that is in my plugin.yml what now I still
    get the error

    when I change it I in the plugin yml to match exactly what the class is and I get this!:
    14:18:05 [SEVERE] Error occurred while enabling Test v0.1 (Is it up to date?)
    java.lang.NoClassDefFoundError: net/milkbowl/vault/permission/Permission
    at com.example.plugin.ExamplePlugin.setupPermissions(ExamplePlugin.java:
    39)
    at com.example.plugin.ExamplePlugin.onEnable(ExamplePlugin.java:29)
    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:215)
    at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader
    .java:337)
    at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManage
    r.java:381)
    at org.bukkit.craftbukkit.CraftServer.loadPlugin(CraftServer.java:256)
    at org.bukkit.craftbukkit.CraftServer.enablePlugins(CraftServer.java:238
    )
    at net.minecraft.server.MinecraftServer.t(MinecraftServer.java:381)
    at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:368)
    at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:197)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:432)
    at net.minecraft.server.ThreadServerApplication.run(SourceFile:492)
    Caused by: java.lang.ClassNotFoundException: net.milkbowl.vault.permission.Permi
    ssion
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.
    java:41)
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.
    java:29)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 12 more

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

    raGan.

    You need vault installed on your test server.
     
  25. Offline

    calebbfmv

    DERP!

    GOD I feel so derpy right now. Thanks now to get this thing to work right.

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

    raGan.

    No problem.
     
  27. Offline

    calebbfmv

    And it is broken again! Oh my god I cannot get this to work right and it is killing me!!
     
  28. Offline

    raGan.

    What now ?
     
  29. Offline

    calebbfmv

  30. Offline

    Firefly

    Why do you have }} 2 brackets at the very bottom of your code? You have some bracket/indenting issues.
     
Thread Status:
Not open for further replies.

Share This Page