CounterStrikeSharp icon indicating copy to clipboard operation
CounterStrikeSharp copied to clipboard

PluginCapability

Open PhantomYopta opened this issue 1 year ago • 3 comments

Could you please add an event to PluginCapability that triggers when a Capability is registered, and also ensure that it is triggered immediately if it's already registered? It's very difficult to deal with when you have a chain of dependencies.

PhantomYopta avatar Mar 15 '24 12:03 PhantomYopta

Currently capabilities are generally registered in the load method and then used from within all plugins loaded. How do you see this flow working? Will plugins register capabilities in all plugins loaded and then listen to the event?

roflmuffin avatar Mar 16 '24 01:03 roflmuffin

let's say there are 3 plugins

api of plugin 2 depends on the api of plugin 1

plugin 3 depends on api of plugin 2, but since plugin 2 depends on plugin 1, plugin 2 will have to register capability in OnAllPluginsLoaded and then plugin 3 will not be able to get api of plugin 2 in OnAllPluginsLoaded.

I think the problem is solved simply if the plugin simply subscribed in Load to the event when the capability was registered Thus a plugin that does not depend on other plugins simply registers capability in OnAllPluginsLoad, and other plugins that already depend on it, subscribe to capability registration in Load and register their api when event occurs.

Muinez avatar Mar 16 '24 13:03 Muinez

Could you please add an event to PluginCapability that triggers when a Capability is registered, and also ensure that it is triggered immediately if it's already registered? It's very difficult to deal with when you have a chain of dependencies.

We had a slight issue when we implemented an event firing / listening flow for Retakes.

For us it was solved by ensuring the dependencies were loaded in the correct order (alphabetically) which required slight file name changes.

I suspect the way we're firing / listening to events in our plugin could be slightly modified to fit your use case.

B3none avatar Mar 21 '24 20:03 B3none