Solved Dependency

Discussion in 'Plugin Development' started by mickverm, Jun 3, 2015.

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

    mickverm

    Hello Everyone, i'm currently making a plugin that depends on Heroes. And i'm trying to get it to check if the plugin is installed, and if it's not installed it should shut the plugin down. But instead it just crashes the plugin. It works fine when Heroes is installed.

    Code:
    [21:55:51 ERROR]: Could not load 'plugins\ManaPotions.jar' in folder 'plugins'
    org.bukkit.plugin.UnknownDependencyException: Heroes
            at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager
    .java:219) [spigot-1.8.3.jar:git-Spigot-870264a-0a645a2]
            at org.bukkit.craftbukkit.v1_8_R2.CraftServer.loadPlugins(CraftServer.ja
    va:291) [spigot-1.8.3.jar:git-Spigot-870264a-0a645a2]
            at net.minecraft.server.v1_8_R2.DedicatedServer.init(DedicatedServer.jav
    a:199) [spigot-1.8.3.jar:git-Spigot-870264a-0a645a2]
            at net.minecraft.server.v1_8_R2.MinecraftServer.run(MinecraftServer.java
    :522) [spigot-1.8.3.jar:git-Spigot-870264a-0a645a2]
    Here's my plugin.yml, nothing special, probably nothing wrong
    Code:
    name: ManaPotions
    main: me.mickverm.ManaPotions.ManaPotions
    version: 0.1
    author: mickverm
    depend: [Heroes]
    And here's part of my code:
    Code:
        @Override
        public void onEnable() {
            if (!setupHeroes()) {
                System.out
                        .println("[SEVERE] ManaPotions disabled due to no Heroes dependency found!");
                System.out
                        .println("[WARNING] ManaPotions can't run without the plugin Heroes!");
                getServer().getPluginManager().disablePlugin(this);
                return;
            }
            this.logger.info(pdfile.getName() + " Version " + pdfile.getVersion()
                    + " Has been Enabled!");
            registerEvents();
            createManaPotion();
        }
    
        @Override
        public void onDisable() {
            this.logger.info(pdfile.getName() + " Has been Disabled!");
        }
    
        private void registerEvents() {
            PluginManager pluginManager = getServer().getPluginManager();
    
            pluginManager.registerEvents(this.playerListener, this);
        }
    
        private boolean setupHeroes() {
            if (getServer().getPluginManager().getPlugin("Heroes") == null) {
                return false;
            } else {
                return true;
            }
        }
    - Mickverm
     
  2. Offline

    Vilsol

    Use "softdepend" rather than "depend", the plugin will be loaded, but if heroes are installed, the plugin will be loaded after heroes.

    http://wiki.bukkit.org/Plugin_YAML
     
    mickverm likes this.
  3. Offline

    mickverm

    Well thank you, I didn't know it was that easy :p
     
Thread Status:
Not open for further replies.

Share This Page