03-01-2014, 11:15 PM
Actually it's been done this way ever since we updated the hooks to support multiple registrations with arbitrary handler functions. It allows us to enclose the full functionality of a part of the plugin into one file, without the need to call any special function.
Consider the WorldEdit plugin, for example. It now uses a cPlayerState Lua class that tracks (almost) all of the state for a single player, including the selection. So it's only natural that it registers the hooks that it needs for keeping track of the selection; the hooks are registered in code outside of any functions, so that it executes as soon as MCS loads the plugin.
The Info.lua file is another example - it lists the commands, permissions, documentation and also the handlers; as such it must be a global structure (so that it can be read by external tools such as InfoDump.lua), yet it has to reference functions that are defined in other files.
Consider the WorldEdit plugin, for example. It now uses a cPlayerState Lua class that tracks (almost) all of the state for a single player, including the selection. So it's only natural that it registers the hooks that it needs for keeping track of the selection; the hooks are registered in code outside of any functions, so that it executes as soon as MCS loads the plugin.
The Info.lua file is another example - it lists the commands, permissions, documentation and also the handlers; as such it must be a global structure (so that it can be read by external tools such as InfoDump.lua), yet it has to reference functions that are defined in other files.