Vault

Vault

7M Downloads

Help with Vault API

ldfuller01 opened this issue ยท 3 comments

commented

Hey there. I've just finished developing a plugin that harnesses VaultAPI, however I have an issue with it. When I "setupEconomy" in my onEnable method, the server console doesn't blurt out a stack trace, but rather tells me that the plugin was not linked to Vault (I have a warning for this coded into the plugin). I've done everything right according to the given code on this website, but the "setupEconomy()" method seems to be returning false, and I have no idea why this is.

Here's the code if you don't mind troubleshooting it. I added a little more completely harmless things to it as well.

public boolean economyIsOn = false;

public static Economy economy = 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;

    }

    economy = rsp.getProvider();

    return economy != null;

}


@Override
public void onEnable() {

    PluginDescriptionFile pdf = this.getDescription();

    logger.info("[" + pdf.getName() + "] " + pdf.getName() + " v" + pdf.getVersion() + " is now enabled.");

    if (!setupEconomy() && getConfig().getBoolean("useEconomy")) {

        economyIsOn = false;

        logger.severe("[" + pdf.getName() +  "] Error setting up economy with Vault! Proceeding without economy!");

    } else if (setupEconomy() && getConfig().getBoolean("useEconomy")) {

        economyIsOn = true;

        logger.info("[" + pdf.getName() + "] Successfully linked to Vault.");

    }

//blah blah, more code after this

}
commented

What economy plugin are you using? And do you have Vault on your test server?

commented

It's hard to debug without any sort of server logs, and as @turt2live mentioned, Vault is not the economy plugin, you'll need to install an economy plugin to utilize that functionality.

commented

.... Oh.... That makes a lot of sense. facepalm Thanks.