2

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.

3 Answers3

0

To your plugin.yml add depend: [Vault]

For more info see this

Lucraft
  • 3
  • 1
  • 5
0

You added vault to loadbefore, which makes your plugin load before vault. If you want vault to load before your plugin, use depend: [Vault,someOtherPlugin,someOtherPlugin,etc].

  • 1
    tried that, read the question. doesn't work. – GamingCraft_hd Jan 08 '21 at 21:52
  • 1
    The behaviour is inconsistent if you have both loadbefore and depend. It is not clear that you have tried it without loadbefore. Please edit your question to make it clear. –  Jan 08 '21 at 21:53
  • i tried to both, without loadbefore and without depend. – GamingCraft_hd Jan 08 '21 at 21:55
  • What he is trying to say is, that he already tried to do it with just depend: [Vault] but it did not work. – Redi Jan 08 '21 at 21:56
  • Strange. Can anyone reproduce it? Doesn't seem to be happening on my end. Maybe try using the [] list format instead of yours, but both should work. (and probably neither does) –  Jan 08 '21 at 22:02
  • tried that aswell. didn't work :/ and please stop commenting, redi. – GamingCraft_hd Jan 08 '21 at 22:08
  • I just created a blank new Java project and replicated your steps. It does not work – Redi Jan 08 '21 at 22:33
0

I fixed it by adding

<scope>provided</scope>

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