Poll: Change the API?
You do not have permission to vote in this poll.
Yes, break all the plugins
85.71%
6 85.71%
No, keep it as is
14.29%
1 14.29%
Total 7 vote(s) 100%
* You voted for this item. [Show Results]

API change in hook-adding
#1
I think we haven't changed the API for some time now, it's time to break everything (cough coughBig Grin )

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?
Reply
Thanks given by:


Messages In This Thread
API change in hook-adding - by xoft - 08-21-2013, 11:00 PM
RE: API change in hook-adding - by NiLSPACE - 08-21-2013, 11:29 PM
RE: API change in hook-adding - by FakeTruth - 08-21-2013, 11:52 PM
RE: API change in hook-adding - by xoft - 08-22-2013, 12:27 AM
RE: API change in hook-adding - by FakeTruth - 08-22-2013, 12:30 AM
RE: API change in hook-adding - by xoft - 08-22-2013, 12:31 AM
RE: API change in hook-adding - by bearbin - 08-22-2013, 12:34 AM
RE: API change in hook-adding - by xoft - 08-22-2013, 12:37 AM
RE: API change in hook-adding - by xoft - 08-22-2013, 05:36 AM
RE: API change in hook-adding - by NiLSPACE - 08-22-2013, 05:51 AM
RE: API change in hook-adding - by bearbin - 08-22-2013, 05:54 AM
RE: API change in hook-adding - by xoft - 08-22-2013, 05:54 AM
RE: API change in hook-adding - by NiLSPACE - 08-22-2013, 08:09 PM
RE: API change in hook-adding - by xoft - 08-22-2013, 09:42 PM
RE: API change in hook-adding - by NiLSPACE - 08-22-2013, 11:27 PM
RE: API change in hook-adding - by bearbin - 08-22-2013, 11:33 PM
RE: API change in hook-adding - by NiLSPACE - 08-22-2013, 11:41 PM
RE: API change in hook-adding - by xoft - 08-22-2013, 11:43 PM
RE: API change in hook-adding - by xoft - 08-23-2013, 04:27 AM
RE: API change in hook-adding - by tonibm19 - 10-20-2013, 11:26 PM
RE: API change in hook-adding - by tigerw - 10-21-2013, 03:37 AM
RE: API change in hook-adding - by bearbin - 10-21-2013, 05:30 AM
RE: API change in hook-adding - by xoft - 10-21-2013, 07:19 AM



Users browsing this thread: 3 Guest(s)