Search code examples
javayamlminecraftbukkitbukkit-vault

Vault loading too late


My Plugin is loading before Vault, even tho I added a depend/load-after into the plugin.yml

I tried depend, softdepend and loadbefore. I even tried downgrading the on the server used version of Vault.

I tried even loadbefore without depend and the other way around.

My plugins.yml

name: TrainsaPlugin
version: ${project.version}
main: de.gamingcraft.trainsa.TrainsaPlugin

(...)

loadbefore:
  - Vault

depend:
  - Vault

commands: (...)

My Main Class:

public final class TrainsaPlugin extends JavaPlugin {

    (...)

    public static Economy econ = null;
    public static Permission perms = null;
    public static Chat chat = null;


    @Override
    public void onEnable() {
        (...)

        if (!setupEconomy() ) {
            System.out.println("Disabled due to no Vault dependency found!");
            getServer().getPluginManager().disablePlugin(this);
            return;
        }
        setupPermissions();
        setupChat();
    }

    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;
    }

    private boolean setupChat() {
        RegisteredServiceProvider<Chat> rsp = getServer().getServicesManager().getRegistration(Chat.class);
        chat = rsp.getProvider();
        return chat != null;
    }

    private boolean setupPermissions() {
        RegisteredServiceProvider<Permission> rsp = getServer().getServicesManager().getRegistration(Permission.class);
        perms = rsp.getProvider();
        return perms != null;
    }

    @Override
    public void onDisable() {
    }

    (...)
}

The Log

[22:35:43 INFO]: [TrainsaPlugin] Disabling TrainsaPlugin v1.0
(...)
[22:35:43 INFO]: Server permissions file permissions.yml is empty, ignoring it
[22:35:43 INFO]: Done (1,912s)! For help, type "help" or "?"
[22:35:43 INFO]: [Vault] Checking for Updates ...

I know, that my main-class disables my plugin when Vault is not found and i want that because it's essential at the moment.

TL;DR: My problem is, that Vault loads too late.


Solution

  • I fixed it by adding

    <scope>provided</scope>
    

    to every dependency, that was a plugin in the pom.xml