LabAPI icon indicating copy to clipboard operation
LabAPI copied to clipboard

[IDEA] Add PluginsLoaded event

Open Xname7 opened this issue 8 months ago • 2 comments

Goal Description

During plugin deployment, users may find compatibility issues between plugins that developer needs to adress. But when should the incompatibility be resolved?

  • MapGenerated or WatitingForPlayers? - What if changes need to be made before these events are fired?
  • Rely on plugin's LoadPriority? - Not reliable, can be changed anytime
  • Coroutine on plugin's Enable method? - Not reliable, will lead to unexpected bugs
  • Some other basegame event? - Not everyone has time or enough knowlege to scatter through server's assembly

PluginsLoaded event would solve all of above dillemas. It will be called as early as possible after all plugins have been loaded and enabled so checking if specific plugin was loaded and act accordingly will not be an issue.

Notes

Where should it be called? And for that I have 2 valid anwsers.

  1. At the end of PluginLoader::Initialize() method - Straight forward, can be done through a PR
  2. After NameFormatter is set inside ServerConsole::Start() method - Needs to be done by someone from LabAPI team, but it also enables registering custom SNCI commands asap so server's name will always be correct

Xname7 avatar Mar 26 '26 11:03 Xname7

Use the enable method for this, it runs when your plugin is enabled. Loading happens before enabling so it's impossible for you to track loading.

Or if you had something else in mind, please clarify.

LumiFae avatar Mar 26 '26 12:03 LumiFae

My idea was to create a standard place for solving compatibility issues (maybe also for registering SNCI commands) that isn’t affected by LoadPriority, and where you can make necessary changes only after someone’s plugin has been successfully enabled.

For example, Plugin A and Plugin B both have feature X and some other features. Plugin A disables its X feature only after Plugin B has been successfully enabled. If Plugin B errors during enabling, Plugin A will still have feature X enabled and working.

Maybe I’m overthinking all of this, but in my head it could prove useful for someone.

Xname7 avatar Mar 26 '26 15:03 Xname7