Vault

Vault

7M Downloads

economy linking not working with many plugins?

zach-all opened this issue ยท 3 comments

commented

Hi,
My link isnt working, if there are many plugins loaded. I tried to find the bug but its not plugin specific and just if more then 30 plugins in the ./plugins folder it doesnt work with one specific plugin, Here is my Code:

RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager().getRegistration(Economy.class);
if(economyProvider != null)
economy = economyProvider.getProvider();
else
{
log.info("["+pdf.getName()+"] Vault error: No economy provider!");
pm.disablePlugin(this);
return;
}
if(!economy.isEnabled())
{
log.info("["+pdf.getName()+"] Vault error: Economy disabled!");
pm.disablePlugin(this);
return;
}
commented

ok thank you very much :)) SOLVED

commented

the number of plugins doesn't effect Vault. You shouldn't be checking the economy enabled status unless you're absolutely certain your plugin loads after your economy. I imagine that it's failing because it thinks your econ is disabled when it loads your plugin.

commented

well the problem is that you are just checking for the provider once... it is a little bit more complicated like that (at least for me).

I use a boolean to signal that an economy provider was found and than check in my code if that is set before I do stuff...

if (checkVault != null && !plugin.isEconomyEnabled()) {
            plugin.setVaultFound(true);
            mainLogger.info("Vault detected");
            mainLogger.info("Checking economy providers now!");
        }
        if (plugin.isVaultFound() && !plugin.isEconomyEnabled()) {
            RegisteredServiceProvider<Economy> economyProvider = plugin.getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
            if (economyProvider != null) {
                plugin.setEconomy(economyProvider.getProvider());
                plugin.setEconomyEnabled(true);
                mainLogger.info("Economy provider found: " + economyProvider.getProvider().getName());
                if (mainConfig.isEnableGetPayed()) {
                    mainConfig.setGetPayedActive(true);
                    mainLogger.info("Activating GetPayed!");
                }

            } else {
                if (missingEconomyWarn) {
                    mainLogger.warning("No economy provider found.");
                    mainLogger.info("Still waiting for economy provider to show up.");
                    missingEconomyWarn = false;
                }
            }
        }