1.15.2 Spigot plugin dependency before onEnable

Discussion in 'Spigot Plugin Development' started by Rafoudiablol, Jul 1, 2020.

  1. How to make a plugin depends to another ? I have PluginCore and PluginExt, PluginExt depends on PluginCore. I have to register some data before PluginCore initialize.
    The problem is that it's a cyclic dependency: the extension depends on the core but the data are treated when the maing plugin is initialized. If the extension register data afterthe initialization of the core, the registered data will be ignored. Of course, there are probably many ways to do it but is there a "clean" or "standard" way ?
    Something like pre-(initialization and post-initialization in Forge. (Maybe can the constructor be used for something like it)

    Code (Text):
    public class PluginCore extends JavaPlugin {
        private List<String> strings = new ArrayList<>();
        public void registerExt(String ext) {
        public void onEnable() {
            // Here strings should be filled
            // I can check later but I would like to check here, maybe there is a deidcated event ?

            for(String s : strings) {
                getLogger().info("Extension: " + s);

    public class PluginExt extends JavaPlugin {
        public void onEnable() {
    Does it works ? I don't know about the order of initialization (all plugin constructor then all plugin onEnable OR. plugin constructor and onEnable() each plugin after the another)
    #1 Rafoudiablol, Jul 1, 2020
    Last edited: Jul 1, 2020
  2. add "depend" on plugin.yml
    Code (Text):
    depend: [PluginCore]
  3. You can use the onLoad() method in your main. This method will be called on loading, this is before the onEnable()
    • Informative Informative x 1
  4. Use the plugin.yml + added a statment method onEnable if you really want it

    Code (Java):
    // if you really want to add a needed plugin message onEnable do:

            if(!Bukkit.getServer().getPluginManager().isPluginEnabled("Plugin-Name")) {
            // send a logger that they need the plugin
            } else {
            // you can just say its installed+implemented
    // use 'depend:' if your plugin depends on the that plguin.
    depend: [Plugin-Name]

    // use 'soft-depend' if its not really needed
    soft-depend: [Plugin-Name]