I think we haven't changed the API for some time now, it's time to break everything (cough cough )
I'd like to propose a change that could make life somewhat easier for plugin authors. This change would allow them to modularize their plugins and possibly to merge multiple plugins into one (as is lately the case of the Core).
The change is subtle at first look: go from
Second, you provide a handler function directly, so you can name it whatever you want. Right? Right.
And even better than that - you can add multiple functions to be called for a single hook. Why would you need that? To illustrate, let's examine the Core. It currently provides SpawnProtect and LimitWorld functionality. Both of these require that an OnPlayerPlacingBlock() handler is provided, so that the player may not place blocks inside the spawn area and outside the world limit. So the code for both needs to be intertwined together in a single OnPlayerPlacingBlock() function. A Big Ball Of Wibbly Wobbly Timey Wimey ... Stuff.
Now, if each "functionality module" could add their own hook, you could split it and have SpawnProtect implemented in a single Lua file, and LimitWorld in another single Lua file, the only thing in common would be a call to each respective InitializeXXX function in the common plugin Initialize() function. Modularity, finally!
What do you say, is this change worth breaking things?
I'd like to propose a change that could make life somewhat easier for plugin authors. This change would allow them to modularize their plugins and possibly to merge multiple plugins into one (as is lately the case of the Core).
The change is subtle at first look: go from
cPluginManager:Get():AddHook(PluginInstance, HOOK_TYPE);to
cPluginManager:Get():AddHook(HOOK_TYPE, HandlerFunction);Two changes here. You no longer need to provide the PluginInstance variable. Yay! It was useless anyway!
Second, you provide a handler function directly, so you can name it whatever you want. Right? Right.
And even better than that - you can add multiple functions to be called for a single hook. Why would you need that? To illustrate, let's examine the Core. It currently provides SpawnProtect and LimitWorld functionality. Both of these require that an OnPlayerPlacingBlock() handler is provided, so that the player may not place blocks inside the spawn area and outside the world limit. So the code for both needs to be intertwined together in a single OnPlayerPlacingBlock() function. A Big Ball Of Wibbly Wobbly Timey Wimey ... Stuff.
Now, if each "functionality module" could add their own hook, you could split it and have SpawnProtect implemented in a single Lua file, and LimitWorld in another single Lua file, the only thing in common would be a call to each respective InitializeXXX function in the common plugin Initialize() function. Modularity, finally!
What do you say, is this change worth breaking things?