From 223967b80d783df1be2df5f74ddf198f373fbc57 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Tue, 12 Jun 2012 21:30:32 +0000 Subject: Added working crafting hooks HOOK_PRE_CRAFTING, HOOK_CRAFTING_NO_RECIPE and HOOK_POST_CRAFTING git-svn-id: http://mc-server.googlecode.com/svn/trunk@598 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cPluginManager.h | 79 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 59 insertions(+), 20 deletions(-) (limited to 'source/cPluginManager.h') diff --git a/source/cPluginManager.h b/source/cPluginManager.h index 8d0a82a39..bf891d085 100644 --- a/source/cPluginManager.h +++ b/source/cPluginManager.h @@ -5,6 +5,18 @@ struct lua_State; class cLuaCommandBinder; class cPlugin; class cPlugin_Lua; + +// fwd: cPlayer.h +class cPlayer; + +// fwd: CraftingRecipes.h +class cCraftingGrid; +class cCraftingRecipe; + + + + + class cPluginManager //tolua_export { //tolua_export public: //tolua_export @@ -12,29 +24,52 @@ public: //tolua_export // Called each tick virtual void Tick(float a_Dt); - enum PluginHook // tolua_export - { // tolua_export - E_PLUGIN_TICK, // tolua_export - E_PLUGIN_CHAT, // tolua_export - E_PLUGIN_COLLECT_ITEM, // tolua_export - E_PLUGIN_BLOCK_DIG, // tolua_export - E_PLUGIN_BLOCK_PLACE, // tolua_export - E_PLUGIN_DISCONNECT, // tolua_export - E_PLUGIN_HANDSHAKE, // tolua_export - E_PLUGIN_LOGIN, // tolua_export - E_PLUGIN_PLAYER_SPAWN, // tolua_export - E_PLUGIN_PLAYER_JOIN, // tolua_export - E_PLUGIN_PLAYER_MOVE, // tolua_export - E_PLUGIN_TAKE_DAMAGE, // tolua_export - E_PLUGIN_KILLED, // tolua_export - E_PLUGIN_CHUNK_GENERATED, // tolua_export - E_PLUGIN_CHUNK_GENERATING, // tolua_export - E_PLUGIN_BLOCK_TO_DROPS, // tolua_export - }; // tolua_export + // tolua_begin + enum PluginHook + { + HOOK_TICK, + HOOK_CHAT, + HOOK_COLLECT_ITEM, + HOOK_BLOCK_DIG, + HOOK_BLOCK_PLACE, + HOOK_DISCONNECT, + HOOK_HANDSHAKE, + HOOK_LOGIN, + HOOK_PLAYER_SPAWN, + HOOK_PLAYER_JOIN, + HOOK_PLAYER_MOVE, + HOOK_TAKE_DAMAGE, + HOOK_KILLED, + HOOK_CHUNK_GENERATED, + HOOK_CHUNK_GENERATING, + HOOK_BLOCK_TO_DROPS, + HOOK_PRE_CRAFTING, /// cPlayer, cCraftingGrid, cCraftingRecipe + HOOK_CRAFTING_NO_RECIPE, /// cPlayer, cCraftingGrid, cCraftingRecipe + HOOK_POST_CRAFTING, /// cPlayer, cCraftingGrid, cCraftingRecipe + + // E_PLUGIN_ names are obsolete, but are kept for compatibility reasons + E_PLUGIN_TICK = HOOK_TICK, + E_PLUGIN_CHAT = HOOK_CHAT, + E_PLUGIN_COLLECT_ITEM = HOOK_COLLECT_ITEM, + E_PLUGIN_BLOCK_DIG = HOOK_BLOCK_DIG, + E_PLUGIN_BLOCK_PLACE = HOOK_BLOCK_PLACE, + E_PLUGIN_DISCONNECT = HOOK_DISCONNECT, + E_PLUGIN_HANDSHAKE = HOOK_HANDSHAKE, + E_PLUGIN_LOGIN = HOOK_LOGIN, + E_PLUGIN_PLAYER_SPAWN = HOOK_PLAYER_SPAWN, + E_PLUGIN_PLAYER_JOIN = HOOK_PLAYER_JOIN, + E_PLUGIN_PLAYER_MOVE = HOOK_PLAYER_MOVE, + E_PLUGIN_TAKE_DAMAGE = HOOK_TAKE_DAMAGE, + E_PLUGIN_KILLED = HOOK_KILLED, + E_PLUGIN_CHUNK_GENERATED = HOOK_CHUNK_GENERATED, + E_PLUGIN_CHUNK_GENERATING = HOOK_CHUNK_GENERATING, + E_PLUGIN_BLOCK_TO_DROPS = HOOK_BLOCK_TO_DROPS, + }; + // tolua_end static cPluginManager * GetPluginManager(); //tolua_export - typedef std::list< cPlugin* > PluginList; + typedef std::list< cPlugin * > PluginList; cPlugin* GetPlugin( const char* a_Plugin ) const; //tolua_export const PluginList & GetAllPlugins() const; // >> EXPORTED IN MANUALBINDINGS << @@ -47,6 +82,10 @@ public: //tolua_export unsigned int GetNumPlugins() const; //tolua_export bool CallHook( PluginHook a_Hook, unsigned int a_NumArgs, ... ); + + bool CallHookPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe); + bool CallHookCraftingNoRecipe(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe); + bool CallHookPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe); void RemoveHooks( cPlugin* a_Plugin ); void RemovePlugin( cPlugin* a_Plugin, bool a_bDelete = false ); //tolua_export -- cgit v1.2.3