plugin load order

  • Is there any way to influence the order plugins get loaded in a server? From my understanding currently they load in alphabetical order or?


    To explain the reason behind the question, we have a messaging plugin that sends messages to players when they spawn (player spawn event) and we want to add a plugin that should again send a message to players on login (again spawn event) but I want that plugin to always send the messages after the other and not before as it currently does. 1st plugin named ServerTools, second plugin named MailingSystem. (so M sends messages before S when I want S to send the messages before M)


    We thought of adding a short timer to the second plugin's messages to make that happen but we are looking for a smarter solution that that :D

  • so i have no idea about coding and so but wouldn't it be the easiest way to rename the plugins or set a number at first letter? i do this with my blueprints - modules got a 9 befor the name, finished objects got a 0 so i must not scroll so much.

  • that could work (didn't think of it, I will give it a try thanks :) ) if the game uses the name of the folder to determine which plugin goes first, if it uses the name of the main class (found in the yml file) then one would have to change thins in the code and recompile it, in my case I can do that if needed but if one of the plugins was written by someone else then I have no control over the name of the main class

  • No this hasn't been solved but we got rid of the other plugin so didn't need a solution in the end.


    Maybe @red51 could give us an answer :/

  • Currently there is no way to guarantee a specific load order. However, some time ago the onEnable() method (which needs to be overridden by the plugin anyway) was changed: It's now only called once all other plugins are fully initialized (this is especially helpful if your plugin depends on another plugin). In addition to that, we added a onLoad() method which can be overridden optionally. It's called when the plugin gets loaded (it's definitely called before onEnable() is called for any other plugins).


    In this particular case (you want to make sure that events are first called for plugin A, then for plugin B?) you could register your event listener for plugin A in the "onLoad()" method, and for plugin B in the "onEnable()" method ;)

  • It is my understanding that plug-ins are first loaded and then enabled in the order in which the underlying operating system lists them when a directory is scanned.


    This order depends on the operating system itself: on Unixes (Linux and OSX) it is basically (but not entirely) the alphabetical order of the file name (probably in some generic locale); on Windows it depends, among other things, on the file creation order.


    The solution proposed by red51 right above is fine for addressing a two-way priority (A always before B), but in general relying on some order of loading / enabling to address plug-in precedence seems to me sub-optimal (for instance, with 3 plug-ins, it might happen that you want A before B, B before C and C before A! Or A before B for some operations and B before A for other operations).


    As the code needs to be adjusted in any case, it would be better to implement the proper precedence in the code itself. Remember that plug-ins can speak to each other!

  • the whole point of my original question was that two plugins were sending some message to the player when they logged in and I wanted my plugin to send the messages after the other plugin (without having to resort to the use of a timer with a few seconds delay). The server was linux and the plugins were loaded alphabetically so I would have to change my plugin's name which I didn't want to do.


    so if a setting like many other games have where you can choose the order plugins get loaded would be great, but not necessary because I just coded the other plugin myself and took the other person's one out of the server. :D

Participate now!

Don’t have an account yet? Create a new account now and be part of our community!