Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no Vault dependency found! #161

Open
JusteLoneWolf opened this issue Oct 4, 2023 · 1 comment
Open

no Vault dependency found! #161

JusteLoneWolf opened this issue Oct 4, 2023 · 1 comment

Comments

@JusteLoneWolf
Copy link

JusteLoneWolf commented Oct 4, 2023

Hi, i have a problem with vault

When i start my server my plugins don't detect Vault but Vault plugins it's present on my plugins folder

image
VaultEconomy is my plugin

image
image

package fr.lonewolf.vaulteconomy;

import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;

public final class VaultEconomy extends JavaPlugin {

    private static Economy economy = null;

    @Override
    public void onEnable() {
        if (!setupEconomy() ) {
            System.out.println("Disabled due to no Vault dependency found!");
            getServer().getPluginManager().disablePlugin(this);
            return;
        }
    }

    private boolean setupEconomy()
    {
        RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
        if (economyProvider != null) {
            economy = economyProvider.getProvider();
        }

        return (economy != null);
    }

    public static Economy getEconomy() {
        return economy;
    }

}

yes it's very basic code for the moment

Anyone know to fix it ?

@Geolykt
Copy link
Contributor

Geolykt commented Oct 4, 2023

It is generally advisable to question what you see: Why would it be null? Why would there be no registered Service Provider for an Economy? Henceforth, why would there be no Economy or if there is one, why isn't it registered at this point? Could it be that it is registered too late?

My hint: You lack the Plugin that registers the economy. Going from the name of your plugin it seems you don't actually want to obtain the current economy but rather register a new one - in that case follow the necessary steps to register an economy. I suppose you'd need to dig a bit deeper into that as I don't remember an easy to grasp guide anywhere. However the gist is that you need to implement vault's Economy interface and register your instance of Economy via https://hub.spigotmc.org/javadocs/spigot/org/bukkit/plugin/ServicesManager.html#register(java.lang.Class,T,org.bukkit.plugin.Plugin,org.bukkit.plugin.ServicePriority).

In the future, such questions are better off asked in the spigot discord if you are using spigot or the paper discord if using paper. If neither apply or you are not using discord then ordinarily I'd recommend the spigot IRC and a bit of patience but with the current state of things I won't. What I'm getting at is that you (as much as anyone else) should not use this issue tracker for these kinds of questions as you generally get far worse response times (Upwards of a day, potentially even more).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants