Hooking into Vault

Discussion in 'Plugin Development' started by danieltabrizian, Jun 1, 2014.

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

    danieltabrizian

    So last few days i am trying to hook my economy plugin into vault but with no succes.

    i asked the vault team and i got examples no real explaination

    so i am here to ask

    what do i need to do to implements Economy from vault???
     
  2. danieltabrizian
    This goes inside the main clas
    Code:java
    1. public static Economy economy = null;


    This goes inside your onEnable() method
    Code:java
    1. if(Bukkit.getPluginManager().getPlugin("Vault") == null || !Bukkit.getPluginManager().getPlugin("Vault").isEnabled()) {
    2. Bukkit.getLogger().warning(ttl + "Vault not found, so some features may not be available");
    3. } else {
    4. setupEconomy();
    5. Bukkit.getLogger().info(ttl + "Vault has been found and hooked into successfully");
    6. }


    This goes anywhere else inside the main class
    Code:java
    1. private boolean setupEconomy() {
    2. RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
    3. if (economyProvider != null) {
    4. economy = economyProvider.getProvider();
    5. }
    6.  
    7. return (economy != null);
    8. }
     
  3. Offline

    danieltabrizian

    i did not ment it that way DJSkepter i want to create a new economy
    i dont want to use an economy i want my plugin to be independant from another economy
     
  4. Offline

    AmShaegar

    Well, then fork the Vault repository on GitHub and look how it's done in the other Plugins. As far as I can remember, the only thing you need to do is to add a new Economy class, register it in the Vault class and create a pull request.
     
  5. Offline

    danieltabrizian

    how do you create a pull request and register it?
     
  6. Offline

    AmShaegar

    Look into the code. It's all there.
     
  7. Offline

    danieltabrizian

    what code, can't you just put a example?
     
  8. Offline

    AmShaegar

  9. Offline

    danieltabrizian

    Well, the vault team said that they new devs need to use the servicemanager to implement your economyclass
     
  10. Offline

    AmShaegar

    The ServiceManager is for hooking into Vault. Not for adding new Economy support to Vault.
     
  11. Offline

    danieltabrizian

  12. Offline

    AmShaegar

    Well, then apperently something changed, recently. And without you telling me what exactly they sent to you I cannot help you.
     
  13. Offline

    danieltabrizian

    See the Gringotts economy project if you need examples on how to make your plugin interface with Vault.https://github.com/MinecraftWars/Gringotts/blob/master/src/main/java/org/gestern/gringotts/api/impl/VaultConnector.java
    I don't provide interfaces for every single economy inside of Vault any longer as too many people are creating their own economies even though they are only used privately or on a couple servers (it's also really annoying when there are already so many working economies that are actively maintained).
     
  14. Offline

    AmShaegar

  15. Offline

    danieltabrizian

    well, that kinda worked it said that it registered my class but when i try to use vault it gives a nullpointer exception

    OMG, i am so stuppid i archieved the same thing 2 days ago but i didnt change my deposit shit to my new class!
    thats just so stupid

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jul 1, 2016
  16. Offline

    xize

  17. Offline

    danieltabrizian

    @xise reload your page
     
  18. Offline

    xize

    danieltabrizian
    my bad I'm on a phone:p, however have you set the soft depends or depend in the plugin.yml for Vault?
     
  19. Offline

    danieltabrizian

    Yes, i am not a new coder im just new to creating aconomys i was a coder at private servers i made things like vault on its own but since allot of servers use vault and plugins too i had to make my economy plugin compatible too!
    i actually did every thing here 2 days ago i just forgot to change my class from normal vault to my new economy!
    i am going to create a new post explaining everything and my journey to figure out how i did it!
    so that other devs dont have to go trough the same way i did!
     
    xize likes this.
  20. Offline

    xize

    danieltabrizian
    Yea a resource could be super nice, since I didn't knew you could hook your plugin in Vault to.
    I always thought I had to ask the developer of Vault to add support for my eco plugin at first while you can actually do it by hooking in Vault:p
     
  21. Offline

    danieltabrizian

    xize its a new feature they said!
     
Thread Status:
Not open for further replies.

Share This Page