Make vault detect if no plugin is hooked?

Discussion in 'Plugin Development' started by TopGear93, Mar 12, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    TopGear93

    How can I make vault detect if an economy, chat, or permissions plugin is not hooked to vault but within my plugin? For example, if I type /givemoney and theres no money plugin hooked to vault how can I make my plugin say "No economy plugin detected" instead of throwing an error?
     
  2. Offline

    RealDope

    Vault's API example covers this. They make a boolean method called setupEconomy(), go look at it.
     
    TopGear93 likes this.
  3. Offline

    seemethere

  4. Offline

    TopGear93

    I've already had this in my plugin since the beginning. I'm not seeing a way to detect if one of the "supported" plugins are unhooked. I must not be seeing something. It shouldn't be this difficult.
     
  5. Offline

    Eballer48

    Here is an example of how I've done in my plugin.

    Code:java
    1.  
    2. private void setupVault() {
    3. if (this.getServer().getPluginManager().getPlugin("Vault") == null) {
    4. this.log.info("[SimpleSpleef] Vault was not found. Economy rewards will not work!");
    5. return;
    6. }
    7.  
    8. ServicesManager manager = this.getServer().getServicesManager();
    9. RegisteredServiceProvider<Economy> e = manager.getRegistration(net.milkbowl.vault.economy.Economy.class);
    10.  
    11. if (e != null) {
    12. SSSettings.getInstance().vault = true;
    13. SSSettings.getInstance().economy = e.getProvider();
    14. } else {
    15. SSSettings.getInstance().vault = false;
    16. this.log.info("[SimpleSpleef] Vault found, but no economy plugin detected. Economy rewards will not work!");
    17. }
    18. }
    19.  
     
    TopGear93 likes this.
  6. Offline

    TopGear93

    ah, now that makes perfect sense :D. Thanks for the help.
     
Thread Status:
Not open for further replies.

Share This Page