Softdepend not working in plugin.yml?

Discussion in 'Plugin Development' started by Milkywayz, Mar 19, 2012.

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

    Milkywayz

    Hey, i have a plugin that soft depends on worldguard, logblock, and vault. When i remove these plugins from my directory to test, it gives this
    PHP:
    15:51:09 [SEVEREPlugin Goldtools is attempting to register event com/sk89q/worldguard/bukkit/WorldGuardPluginwhich does not existIgnoring events registered in class net.milkycraft.Listeners.MyGoldListener
    In that listener i have a import for worldguard. This is my main class:
    PHP:
    package net.milkycraft;
     
    import java.util.logging.Logger;
     
    import net.milkbowl.vault.economy.Economy;
    import net.milkycraft.CommandHandlers.MyGoldCommandExecutor;
    import net.milkycraft.CommandHandlers.MyGoldyCommandExecutor;
    import net.milkycraft.Configuration.Configuration;
    import net.milkycraft.Listeners.MyBlockListener;
    import net.milkycraft.Listeners.MyGoldListener;
     
    import org.bukkit.block.Block;
    import org.bukkit.block.BlockState;
    import org.bukkit.plugin.Plugin;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.RegisteredServiceProvider;
     
    import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
     
    import de.diddiz.LogBlock.Consumer;
    import de.diddiz.LogBlock.LogBlock;
     
    public class 
    Goldtools extends PluginWrapper {
        private 
    Configuration config;
        public static 
    WorldGuardPlugin worldguardPlugin null;
        public static 
    Consumer lbconsumer null;
        public static 
    Logger log Logger.getLogger("Minecraft");
        public static 
    Economy econ null;
        @
    Override
        
    public void onEnable() {
            
    setupPluginDependencies();
            
    //variables
            
    PluginManager pm getServer().getPluginManager();
            
    //listeners
            
    final MyGoldListener goldListener = new MyGoldListener(this);
            final 
    MyBlockListener blockListener = new MyBlockListener();
            
    pm.registerEvents(goldListenerthis);
            
    pm.registerEvents(blockListenerthis); 
            
    //executors
            
    MyGoldCommandExecutor myGoldExecutor;
            
    myGoldExecutor = new MyGoldCommandExecutor(this);
            
    getCommand("goldtools").setExecutor(myGoldExecutor);
            
    MyGoldyCommandExecutor myGoldyExecutor;
            
    myGoldyExecutor = new MyGoldyCommandExecutor(this);
            
    getCommand("gold").setExecutor(myGoldyExecutor);                 
            
    //configuration
            
    config = new Configuration(this);
            
    config.create();
            
    config.reload();     
            } 
        @
    Override
        
    public void onDisable() { log.info(getDescription().getName() + " " getDescription().getVersion() + " unloaded."); }
     
        private 
    void setupPluginDependencies() {
            try {
                
    setupWorldGuard();
            } catch (
    Exception e) {
                
    log.warning("[Goldtools] Failed to load WorldGuard");
                
    e.printStackTrace();
            }
            try {
                
    setupLogBlock();
            } catch (
    Exception e) {
                
    log.warning("[Goldtools] Failed to load LogBlock");
                
    e.printStackTrace();
            }
            try {
                
    setupEconomy();
            } catch (
    Exception e) {
                
    log.warning("[Goldtools] Failed to load Vault");
                
    e.printStackTrace();
            }
        }
        private 
    void setupLogBlock() {
            
    // Register logblock plugin so that we can send break event notices to it
            
    final Plugin logBlockPlugin getServer().getPluginManager().getPlugin("LogBlock");
            if (
    logBlockPlugin != null) {
                
    lbconsumer = ((LogBlock)logBlockPlugin).getConsumer();
                
    log.info("[Goldtools] Hooked into LogBlock!");
            } else {
                
    log.warning("[Goldtools] Failed to load LogBlock");
            }
        }
        private 
    boolean setupEconomy() {
            if (
    getServer().getPluginManager().getPlugin("Vault") == null) {
                
    econ null;
                
    log.warning("[Goldtools] Vault not found, economy support disabled");
            } else {
            
    log.info("[Goldtools] Hooked into Vault!");
            }
            if (
    getServer().getPluginManager().getPlugin("Vault") == null) {
                return 
    false;
            }
            
    RegisteredServiceProvider<Economyrsp getServer().getServicesManager().getRegistration(Economy.class);
            if (
    rsp == null) {
                return 
    false;
            }
            
    econ rsp.getProvider();
            return 
    econ != null;
        }
        private 
    void setupWorldGuard() {
            
    Plugin wg this.getServer().getPluginManager().getPlugin("WorldGuard");
            if (
    wg == null) {
                
    log.info("[Goldtools] Couldn't hook into worldguard");
            } else {
                
    Goldtools.worldguardPlugin = (WorldGuardPlugin)wg;
                
    log.info("[Goldtools] Hooked into WorldGuard!");         
            }
        }
        public 
    boolean queueBlockBreak(String playerNameBlock block)
        {
            if (
    block == null) {
                
    log.warning("Queueblockbreak: block is null - this should not happen!");         
                return 
    false;
            }
            if (
    lbconsumer != null) {
                
    BlockState before block.getState();
                
    lbconsumer.queueBlockBreak(playerNamebefore);
            }
            return 
    true;
        }
                    public 
    Configuration config(){
                        return 
    config;
                    }
    }
    This is my plugin.yml :
    PHP:
    nameGoldtools
    version
    2.0
    description
    Golden tools re imagined!
    authormilkywayz
    website
    http://milkycraft.net
     
    mainnet.milkycraft.Goldtools
    softdepend
    : [WorldGuardVaultLogBlock]
     
    commands:
        
    gold:
          
    descriptionConvert tools to gold!
        
    goldtools:
          
    descriptionView info on this plugin
          aliases
    gt 
    Are i not allowed to use other plugins in other classes..? Thats strange..
     
  2. Offline

    kumpelblase2

    because you try to use the classes from those plugins, which are, since you removed them, not there. You should register the events depending on which plugins are accessible.
     
  3. Offline

    Milkywayz

    Yeah i did had that but scrapped it because i thought using soft depend would just cancel imports with invalid plugins. This means i need 2 classes instead of just one to do the same thing but the only difference is one doesn't use those invalid imports. Wtf
     
  4. Offline

    kumpelblase2

    I don't have problems using imports of classes that may not exist. The only problem is when using those classes.
     
  5. Offline

    Milkywayz

    I figured out the problem, i think. I forgot to change the listener to use the main class for getting worldguard.
     
Thread Status:
Not open for further replies.

Share This Page