Vault economy issue
JonathanBrouwer opened this issue ยท 5 comments
I am making an plugin, and decided to include economy in it. (An economy-providing plugin like iConomy, CraftConomy, Essentials economy, etc)
Everything works fine, I registered the plugin using this:
Bukkit.getServicesManager().register(Economy.class, new UEconomy(), Bukkit.getPluginManager().getPlugin("Vault"), ServicePriority.Low);
When I use the /vault-info command it says:
Economy: UltimateCore [UltimateCore] (my plugin)
Testing my plugin using this works fine
log("Testing Vault economy...");
Economy economy = null;
RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
if (economyProvider != null) {
economy = economyProvider.getProvider();
}
log("Name: " + economy.getName());
OfflinePlayer pl = r.searchOfflinePlayer("Bammerbom");
log("Balance before: " + economy.getBalance(pl));
economy.depositPlayer(pl, 10.0);
log("Balance after: " + economy.getBalance(pl));
But strange enough, whenever other plugins that depend on vault try to acces UltimateCore economy, it seems to fail, for example getBalance() returns 0.0 (No exceptions are thrown). And the methods in the UltimateCore economy class (https://github.com/Bammerbom/UltimateCore/blob/master/src/main/java/bammerbom/ultimatecore/bukkit/api/UEconomy.java) Are not getting called! (I tried this my logging a message every time a method is called, but it didnt work)
What am I doing wrong?
Make sure you are setting your plugin to load in the startup stage, not the default stage.
Is there any other way to do this? loading in startup stage seems to break my whole plugin
Or is it possible to load a certain part of my plugin on startup and everything else on the default stage?
I think I found a way, I am now registering my plugin in initialize and it works.