Trying to hook into vault

Discussion in 'Spigot Plugin Development' started by craterhater, May 29, 2017.

  1. Hey there,

    I am currently trying to hook into vault using this code:

    Code (Text):
    if (!setupEconomy()) {
                Bukkit.getConsoleSender().sendMessage(ChatColor.WHITE + "Could not find vault, no worries though! It is totally optional!");
            }
    Code (Text):
    public static Economy econ = null;
        private boolean setupEconomy() {
            if (getServer().getPluginManager().getPlugin("Vault") == null) {
                return false;
            }
            RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
            if (rsp == null) {
                return false;
            }
            econ = rsp.getProvider();
            return econ != null;
        }
    However, this always sends the consolesender a message even when I got vault in my plugins folder.

    This is my plugin.yml:

    Code (Text):
    name: Plugin Name
    version: 1.0.0
    main: main.Main
    author: CraterHater
    description: Plugin Description
    depend: [Vault]
    Thanks!
     
  2. You must have a plugin that should register to Vault too, not only having Vault. Example: Essentials.
     
  3. Oh, that makes it a lot more complicated doesn't it?
     
  4. Nope it doesn't, Vault is based on something that has to register to it so the Economy will work. Basically Vault is something like an API for other plugins that have Economy System.

    Code (Text):
            if (!setupEconomy() ) {
                log.severe(String.format("[%s] - Disabled due to no Vault dependency found! Make sure you have Vault and also Essentials or other plugin so Vault can register to it!", getDescription().getName()));
                getServer().getPluginManager().disablePlugin(this);
                return;
            }
     
  5. So what exactly do I have to do?
     
  6. Download Essentials, it should work.
     
  7. Alright, I'll try.
     
  8. I'll be here.
     
  9. I am getting this error:
    "Essentials API is called before Essentials is loaded"
     
  10. What have you downloaded? you don't download any Essentials API, you download the basic Essentials.

    Essentials-2.x-SNAPSHOT
    EssentialsAntiBuild-2.x-SNAPSHOT
    EssentialsChat-2.x-SNAPSHOT
    EssentialsGeoIP-2.x-SNAPSHOT
    EssentialsSpawn-2.x-SNAPSHOT

    Also don't forget Vault and Essentials have to be the same version if i am right.
     
  11. I did, I downloaded this one:
    https://dev.bukkit.org/projects/essentials