Solved Checking for Core Plugins

Discussion in 'Spigot Plugin Development' started by Hunky524, May 11, 2016.

  1. I'm sure this has to have been discussed many times on forums before, but I just can't seem to type the right combinations of words into google to find it. Anyway, I'm wondering how you can check if a core plugin has been installed on a server before initializing the child plugin. For example if you had two plugins, one named ServerCore and the other named ServerGames. How can you make ServerGames only run if ServerCore is also installed. Is it also possible to check the plugin version as well?
     
  2. just add ServerCore to the dependencies of ServerGames (in plugin.yml). As for the version check, just get the Plugin through PluginManager, get the PluginDescriptionFile from the Plugin and get the version from the PluginDescriptionFile.
     
  3. loadbefore: [plugin] I believe or just depend
     
  4. Oh, not as hard as I was expecting. Thanks :)
     
  5. Code (Java):
            final Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("Core");
            if (plugin == null || !(plugin instanceof Core)) {
                super.getLogger().info("<--------------------------->");
                super.getLogger().info("You are missing the Core, or something went wrong!");
                super.getLogger().info("<--------------------------->");
                Bukkit.getPluginManager().disablePlugin(this);
                return;
            }
    the fun way... lol, then just put that into a repeated task and every 5 seconds check for the plugin and if it's true, register everything and let the plugin run :)