2012-06-14 06:06:06 -07:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2012-09-23 15:09:57 -07:00
|
|
|
#include "Item.h"
|
2012-06-14 06:06:06 -07:00
|
|
|
|
|
|
|
struct lua_State;
|
|
|
|
class cLuaCommandBinder;
|
2012-11-08 11:09:35 -08:00
|
|
|
|
|
|
|
#ifdef USE_SQUIRREL
|
|
|
|
class cSquirrelCommandBinder;
|
|
|
|
#endif // USE_SQUIRREL
|
|
|
|
|
2012-06-14 06:06:06 -07:00
|
|
|
class cPlugin;
|
|
|
|
|
2012-12-21 03:04:08 -08:00
|
|
|
// fwd: World.h
|
2012-06-14 10:30:37 -07:00
|
|
|
class cWorld;
|
|
|
|
|
2013-01-25 02:12:29 -08:00
|
|
|
// fwd: ChunkDesc.h
|
|
|
|
class cChunkDesc;
|
2012-06-14 10:30:37 -07:00
|
|
|
|
2012-12-21 03:04:08 -08:00
|
|
|
// fwd: Player.h
|
2012-06-14 06:06:06 -07:00
|
|
|
class cPlayer;
|
|
|
|
|
|
|
|
// fwd: CraftingRecipes.h
|
|
|
|
class cCraftingGrid;
|
|
|
|
class cCraftingRecipe;
|
|
|
|
|
2012-12-21 03:04:08 -08:00
|
|
|
// fwd: Pickup.h
|
2012-08-24 02:49:00 -07:00
|
|
|
class cPickup;
|
|
|
|
|
2012-12-21 03:04:08 -08:00
|
|
|
// fwd: Pawn.h
|
|
|
|
struct TakeDamageInfo;
|
|
|
|
class cPawn;
|
|
|
|
|
2012-06-14 06:06:06 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-01-11 20:46:01 -08:00
|
|
|
class cPluginManager // tolua_export
|
|
|
|
{ // tolua_export
|
|
|
|
public: // tolua_export
|
2012-06-14 06:06:06 -07:00
|
|
|
|
|
|
|
// Called each tick
|
|
|
|
virtual void Tick(float a_Dt);
|
|
|
|
|
|
|
|
// tolua_begin
|
|
|
|
enum PluginHook
|
|
|
|
{
|
2013-01-26 18:00:33 -08:00
|
|
|
HOOK_BLOCK_TO_PICKUPS,
|
2012-06-14 06:06:06 -07:00
|
|
|
HOOK_CHAT,
|
2013-01-11 20:46:01 -08:00
|
|
|
HOOK_CHUNK_GENERATED,
|
|
|
|
HOOK_CHUNK_GENERATING,
|
2013-01-28 08:17:26 -08:00
|
|
|
HOOK_COLLECTING_PICKUP,
|
2013-01-11 20:46:01 -08:00
|
|
|
HOOK_CRAFTING_NO_RECIPE,
|
2012-06-14 06:06:06 -07:00
|
|
|
HOOK_DISCONNECT,
|
|
|
|
HOOK_HANDSHAKE,
|
|
|
|
HOOK_KILLED,
|
2013-01-11 20:46:01 -08:00
|
|
|
HOOK_LOGIN,
|
|
|
|
HOOK_PLAYER_BREAKING_BLOCK,
|
|
|
|
HOOK_PLAYER_BROKEN_BLOCK,
|
|
|
|
HOOK_PLAYER_EATING,
|
|
|
|
HOOK_PLAYER_JOINED,
|
|
|
|
HOOK_PLAYER_LEFT_CLICK,
|
2013-01-25 23:50:06 -08:00
|
|
|
HOOK_PLAYER_MOVING,
|
2013-01-11 20:46:01 -08:00
|
|
|
HOOK_PLAYER_PLACED_BLOCK,
|
|
|
|
HOOK_PLAYER_PLACING_BLOCK,
|
2013-01-18 10:28:27 -08:00
|
|
|
HOOK_PLAYER_RIGHT_CLICK,
|
2013-01-11 20:46:01 -08:00
|
|
|
HOOK_PLAYER_SHOOTING,
|
|
|
|
HOOK_PLAYER_SPAWNED,
|
|
|
|
HOOK_PLAYER_TOSSING_ITEM,
|
|
|
|
HOOK_PLAYER_USED_BLOCK,
|
|
|
|
HOOK_PLAYER_USED_ITEM,
|
|
|
|
HOOK_PLAYER_USING_BLOCK,
|
|
|
|
HOOK_PLAYER_USING_ITEM,
|
|
|
|
HOOK_POST_CRAFTING,
|
|
|
|
HOOK_PRE_CRAFTING,
|
|
|
|
HOOK_TAKE_DAMAGE,
|
|
|
|
HOOK_TICK,
|
|
|
|
HOOK_UPDATED_SIGN,
|
|
|
|
HOOK_UPDATING_SIGN,
|
|
|
|
HOOK_WEATHER_CHANGED,
|
2012-06-14 06:06:06 -07:00
|
|
|
|
2013-01-11 20:46:01 -08:00
|
|
|
// Note that if a hook type is added, it may need processing in cPlugin::CanAddHook() descendants!
|
|
|
|
} ;
|
2012-06-14 06:06:06 -07:00
|
|
|
// tolua_end
|
|
|
|
|
2013-01-11 20:46:01 -08:00
|
|
|
static cPluginManager * GetPluginManager(); // tolua_export
|
2012-06-14 06:06:06 -07:00
|
|
|
|
2012-10-13 16:34:47 -07:00
|
|
|
typedef std::map< AString, cPlugin * > PluginMap;
|
2012-06-14 06:06:06 -07:00
|
|
|
typedef std::list< cPlugin * > PluginList;
|
2013-01-11 20:46:01 -08:00
|
|
|
cPlugin * GetPlugin( const AString & a_Plugin ) const; // tolua_export
|
2012-10-13 16:34:47 -07:00
|
|
|
const PluginMap & GetAllPlugins() const; // >> EXPORTED IN MANUALBINDINGS <<
|
2012-06-14 06:06:06 -07:00
|
|
|
|
2013-01-11 20:46:01 -08:00
|
|
|
void FindPlugins(); // tolua_export
|
|
|
|
void ReloadPlugins(); // tolua_export
|
2012-06-14 06:06:06 -07:00
|
|
|
bool AddPlugin( cPlugin* a_Plugin );
|
2013-01-11 20:46:01 -08:00
|
|
|
void AddHook( cPlugin* a_Plugin, PluginHook a_Hook ); // tolua_export
|
|
|
|
|
|
|
|
unsigned int GetNumPlugins() const; // tolua_export
|
|
|
|
|
2013-01-26 18:00:33 -08:00
|
|
|
bool CallHookBlockToPickups (cWorld * a_World, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, cItems & a_Pickups);
|
2013-01-11 20:46:01 -08:00
|
|
|
bool CallHookChat (cPlayer * a_Player, const AString & a_Message);
|
|
|
|
bool CallHookChunkGenerated (cWorld * a_World, int a_ChunkX, int a_ChunkZ);
|
2013-01-25 02:12:29 -08:00
|
|
|
bool CallHookChunkGenerating (cWorld * a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_Chunk);
|
2013-01-28 08:17:26 -08:00
|
|
|
bool CallHookCollectingPickup (cPlayer * a_Player, cPickup & a_Pickup);
|
2013-01-11 20:46:01 -08:00
|
|
|
bool CallHookCraftingNoRecipe (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe);
|
|
|
|
bool CallHookDisconnect (cPlayer * a_Player, const AString & a_Reason);
|
|
|
|
bool CallHookHandshake (cClientHandle * a_ClientHandle, const AString & a_Username);
|
|
|
|
bool CallHookKilled (cPawn & a_Victim, cEntity * a_Killer);
|
|
|
|
bool CallHookLogin (cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username);
|
|
|
|
bool CallHookPlayerBreakingBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
|
|
|
|
bool CallHookPlayerBrokenBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
|
|
|
|
bool CallHookPlayerEating (cPlayer & a_Player);
|
|
|
|
bool CallHookPlayerJoined (cPlayer & a_Player);
|
2013-01-25 23:50:06 -08:00
|
|
|
bool CallHookPlayerMoving (cPlayer & a_Player);
|
2013-01-11 20:46:01 -08:00
|
|
|
bool CallHookPlayerLeftClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status);
|
|
|
|
bool CallHookPlayerPlacedBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
|
|
|
|
bool CallHookPlayerPlacingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
|
|
|
|
bool CallHookPlayerRightClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ);
|
|
|
|
bool CallHookPlayerShooting (cPlayer & a_Player);
|
|
|
|
bool CallHookPlayerSpawned (cPlayer & a_Player);
|
|
|
|
bool CallHookPlayerTossingItem (cPlayer & a_Player);
|
|
|
|
bool CallHookPlayerUsedBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
|
|
|
|
bool CallHookPlayerUsedItem (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ);
|
|
|
|
bool CallHookPlayerUsingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
|
|
|
|
bool CallHookPlayerUsingItem (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ);
|
|
|
|
bool CallHookPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe);
|
|
|
|
bool CallHookPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe);
|
|
|
|
bool CallHookTakeDamage (cPawn & a_Receiver, TakeDamageInfo & a_TDI);
|
|
|
|
bool CallHookUpdatedSign (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player);
|
|
|
|
bool CallHookUpdatingSign (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4, cPlayer * a_Player);
|
|
|
|
bool CallHookWeatherChanged (cWorld * a_World);
|
|
|
|
|
|
|
|
bool DisablePlugin( AString & a_PluginName ); // tolua_export
|
|
|
|
bool LoadPlugin( AString & a_PluginName ); // tolua_export
|
2012-10-13 16:34:47 -07:00
|
|
|
|
|
|
|
void RemoveHooks( cPlugin * a_Plugin );
|
|
|
|
void RemovePlugin( cPlugin * a_Plugin, bool a_bDelete = false );
|
2012-07-09 08:53:17 -07:00
|
|
|
|
2012-06-14 06:06:06 -07:00
|
|
|
cLuaCommandBinder* GetLuaCommandBinder() const { return m_LuaCommandBinder; }
|
2012-07-09 08:53:17 -07:00
|
|
|
|
2012-11-08 11:09:35 -08:00
|
|
|
#ifdef USE_SQUIRREL
|
|
|
|
cSquirrelCommandBinder * GetSquirrelCommandBinder() { return m_SquirrelCommandBinder; }
|
|
|
|
#endif // USE_SQUIRREL
|
2012-06-14 06:06:06 -07:00
|
|
|
|
|
|
|
bool HasPlugin( cPlugin* a_Plugin ) const;
|
2012-11-08 11:09:35 -08:00
|
|
|
|
2012-06-14 06:06:06 -07:00
|
|
|
private:
|
2012-11-08 11:09:35 -08:00
|
|
|
|
2012-06-14 06:06:06 -07:00
|
|
|
friend class cRoot;
|
2012-11-08 11:09:35 -08:00
|
|
|
|
2012-06-14 06:06:06 -07:00
|
|
|
cPluginManager();
|
|
|
|
~cPluginManager();
|
|
|
|
|
|
|
|
typedef std::map< cPluginManager::PluginHook, cPluginManager::PluginList > HookMap;
|
|
|
|
|
2012-10-13 16:34:47 -07:00
|
|
|
PluginList m_DisablePluginList;
|
|
|
|
|
|
|
|
PluginMap m_Plugins;
|
2012-06-14 06:06:06 -07:00
|
|
|
HookMap m_Hooks;
|
|
|
|
|
|
|
|
void ReloadPluginsNow();
|
|
|
|
void UnloadPluginsNow();
|
2012-07-09 08:53:17 -07:00
|
|
|
|
2012-11-08 11:09:35 -08:00
|
|
|
cLuaCommandBinder * m_LuaCommandBinder;
|
|
|
|
|
|
|
|
#ifdef USE_SQUIRREL
|
|
|
|
cSquirrelCommandBinder * m_SquirrelCommandBinder;
|
|
|
|
#endif // USE_SQUIRREL
|
2012-06-14 06:06:06 -07:00
|
|
|
|
|
|
|
bool m_bReloadPlugins;
|
2013-01-11 20:46:01 -08:00
|
|
|
}; // tolua_export
|
2012-11-08 11:09:35 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|