diff options
author | cedeel@gmail.com <cedeel@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-06-14 15:06:06 +0200 |
---|---|---|
committer | cedeel@gmail.com <cedeel@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-06-14 15:06:06 +0200 |
commit | 92c59963f82f81aa3202657e7fdbb2592924ede3 (patch) | |
tree | b7eb2474528a4998fa102e3ec9119b908cee08b4 /source/cPlugin.h | |
parent | Added HOOK_WEATHER_CHANGE. (diff) | |
download | cuberite-92c59963f82f81aa3202657e7fdbb2592924ede3.tar cuberite-92c59963f82f81aa3202657e7fdbb2592924ede3.tar.gz cuberite-92c59963f82f81aa3202657e7fdbb2592924ede3.tar.bz2 cuberite-92c59963f82f81aa3202657e7fdbb2592924ede3.tar.lz cuberite-92c59963f82f81aa3202657e7fdbb2592924ede3.tar.xz cuberite-92c59963f82f81aa3202657e7fdbb2592924ede3.tar.zst cuberite-92c59963f82f81aa3202657e7fdbb2592924ede3.zip |
Diffstat (limited to 'source/cPlugin.h')
-rw-r--r-- | source/cPlugin.h | 226 |
1 files changed, 113 insertions, 113 deletions
diff --git a/source/cPlugin.h b/source/cPlugin.h index 4c72b300e..4d32396e8 100644 --- a/source/cPlugin.h +++ b/source/cPlugin.h @@ -1,113 +1,113 @@ -
-#pragma once
-
-#include "cItem.h"
-
-class cPacket_BlockPlace;
-class cPacket_PickupSpawn;
-class cPacket_EntityEquipment;
-class cPacket_Disconnect;
-class cPacket_Chat;
-class cPacket_BlockDig;
-class cPacket_Login;
-class cClientHandle;
-class cPlayer;
-class cPickup;
-class cItem;
-class cEntity;
-class cPawn;
-class cWorld;
-class cLuaChunk;
-struct TakeDamageInfo;
-
-// fwd: cPlayer.h
-class cPlayer;
-
-// fwd: CraftingRecipes.h
-class cCraftingGrid;
-class cCraftingRecipe;
-
-
-
-
-
-// tolua_begin
-class cPlugin
-{
-public:
- cPlugin();
- virtual ~cPlugin();
-
- virtual void OnDisable() {}
- virtual bool Initialize() = 0;
-
- // Called each tick
- virtual void Tick(float a_Dt);
-
- /**
- * On all these functions, return true if you want to override default behavior
- * You can also return false, so default behavior is used, but with changed PacketData
- **/
- virtual bool OnCollectItem (cPickup* a_Pickup, cPlayer* a_Player );
- virtual bool OnDisconnect (const AString & a_Reason, cPlayer * a_Player );
- virtual bool OnBlockPlace (cPacket_BlockPlace* a_PacketData, cPlayer* a_Player );
- virtual bool OnBlockDig (cPacket_BlockDig * a_PacketData, cPlayer* a_Player, cItem* a_PickupItem ) { (void)a_PacketData; (void)a_Player; (void)a_PickupItem; return false; }
- virtual bool OnChat (const char * a_Chat, cPlayer* a_Player );
- virtual bool OnLogin (cPacket_Login* a_PacketData );
- virtual void OnPlayerSpawn (cPlayer* a_Player );
- virtual bool OnPlayerJoin (cPlayer* a_Player );
- virtual void OnPlayerMove (cPlayer* a_Player ) { (void)a_Player; }
- virtual void OnTakeDamage (cPawn* a_Pawn, TakeDamageInfo* a_TakeDamageInfo ) { (void)a_Pawn; (void)a_TakeDamageInfo; }
- virtual bool OnKilled (cPawn* a_Killed, cEntity* a_Killer ) { (void)a_Killed; (void)a_Killer; return false; }
- virtual void OnChunkGenerated (cWorld * a_World, int a_ChunkX, int a_ChunkZ) {}
- virtual bool OnChunkGenerating (int a_ChunkX, int a_ChunkZ, cLuaChunk * a_pLuaChunk ) { return false; }
- virtual bool OnPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) {return false; }
- virtual bool OnCraftingNoRecipe(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) {return false; }
- virtual bool OnPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) {return false; }
- virtual bool OnBlockToPickup (BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, const cPlayer * a_Player, const cItem & a_EquippedItem, cItems & a_Pickups) {return false; }
-
- // Accessors
- const char* GetName() const { return m_Name.c_str(); }
- void SetName( const char* a_Name ) { m_Name = a_Name; }
-
- int GetVersion() const { return m_Version; }
- void SetVersion( int a_Version ) { m_Version = a_Version; }
-
- struct CommandStruct
- {
- std::string Command;
- std::string Description;
- std::string Permission;
- };
-
- void AddCommand( std::string & a_Command, std::string & a_Description, std::string & a_Permission );
- // tolua_end
- typedef bool (FuncCommandHandler)( std::string & a_Command, std::vector< std::string > & a_Split );
- void BindCommand( FuncCommandHandler* a_Function, std::string & a_Command ); // >> EXPORTED IN MANUALBINDINGS <<
- const std::vector< CommandStruct > & GetCommands() const { return m_Commands; } // >> EXPORTED IN MANUALBINDINGS <<
-
-
- /* This should not be exposed to scripting languages */
- enum PluginLanguage
- {
- E_CPP,
- E_LUA,
- E_SQUIRREL,
- };
- PluginLanguage GetLanguage() { return m_Language; }
- void SetLanguage( PluginLanguage a_Language ) { m_Language = a_Language; }
-
- bool CanBindCommands() { return m_bCanBindCommands; }
-private:
- friend class cPluginManager;
- bool m_bCanBindCommands; // Only changed by cPluginManager
-
- PluginLanguage m_Language;
- std::vector< CommandStruct > m_Commands;
- std::string m_Name;
- int m_Version;
-}; //tolua_export
-
-
-
-
+ +#pragma once + +#include "cItem.h" + +class cPacket_BlockPlace; +class cPacket_PickupSpawn; +class cPacket_EntityEquipment; +class cPacket_Disconnect; +class cPacket_Chat; +class cPacket_BlockDig; +class cPacket_Login; +class cClientHandle; +class cPlayer; +class cPickup; +class cItem; +class cEntity; +class cPawn; +class cWorld; +class cLuaChunk; +struct TakeDamageInfo; + +// fwd: cPlayer.h +class cPlayer; + +// fwd: CraftingRecipes.h +class cCraftingGrid; +class cCraftingRecipe; + + + + + +// tolua_begin +class cPlugin +{ +public: + cPlugin(); + virtual ~cPlugin(); + + virtual void OnDisable() {} + virtual bool Initialize() = 0; + + // Called each tick + virtual void Tick(float a_Dt); + + /** + * On all these functions, return true if you want to override default behavior + * You can also return false, so default behavior is used, but with changed PacketData + **/ + virtual bool OnCollectItem (cPickup* a_Pickup, cPlayer* a_Player ); + virtual bool OnDisconnect (const AString & a_Reason, cPlayer * a_Player ); + virtual bool OnBlockPlace (cPacket_BlockPlace* a_PacketData, cPlayer* a_Player ); + virtual bool OnBlockDig (cPacket_BlockDig * a_PacketData, cPlayer* a_Player, cItem* a_PickupItem ) { (void)a_PacketData; (void)a_Player; (void)a_PickupItem; return false; } + virtual bool OnChat (const char * a_Chat, cPlayer* a_Player ); + virtual bool OnLogin (cPacket_Login* a_PacketData ); + virtual void OnPlayerSpawn (cPlayer* a_Player ); + virtual bool OnPlayerJoin (cPlayer* a_Player ); + virtual void OnPlayerMove (cPlayer* a_Player ) { (void)a_Player; } + virtual void OnTakeDamage (cPawn* a_Pawn, TakeDamageInfo* a_TakeDamageInfo ) { (void)a_Pawn; (void)a_TakeDamageInfo; } + virtual bool OnKilled (cPawn* a_Killed, cEntity* a_Killer ) { (void)a_Killed; (void)a_Killer; return false; } + virtual void OnChunkGenerated (cWorld * a_World, int a_ChunkX, int a_ChunkZ) {} + virtual bool OnChunkGenerating (int a_ChunkX, int a_ChunkZ, cLuaChunk * a_pLuaChunk ) { return false; } + virtual bool OnPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) {return false; } + virtual bool OnCraftingNoRecipe(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) {return false; } + virtual bool OnPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) {return false; } + virtual bool OnBlockToPickup (BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, const cPlayer * a_Player, const cItem & a_EquippedItem, cItems & a_Pickups) {return false; } + + // Accessors + const char* GetName() const { return m_Name.c_str(); } + void SetName( const char* a_Name ) { m_Name = a_Name; } + + int GetVersion() const { return m_Version; } + void SetVersion( int a_Version ) { m_Version = a_Version; } + + struct CommandStruct + { + std::string Command; + std::string Description; + std::string Permission; + }; + + void AddCommand( std::string & a_Command, std::string & a_Description, std::string & a_Permission ); + // tolua_end + typedef bool (FuncCommandHandler)( std::string & a_Command, std::vector< std::string > & a_Split ); + void BindCommand( FuncCommandHandler* a_Function, std::string & a_Command ); // >> EXPORTED IN MANUALBINDINGS << + const std::vector< CommandStruct > & GetCommands() const { return m_Commands; } // >> EXPORTED IN MANUALBINDINGS << + + + /* This should not be exposed to scripting languages */ + enum PluginLanguage + { + E_CPP, + E_LUA, + E_SQUIRREL, + }; + PluginLanguage GetLanguage() { return m_Language; } + void SetLanguage( PluginLanguage a_Language ) { m_Language = a_Language; } + + bool CanBindCommands() { return m_bCanBindCommands; } +private: + friend class cPluginManager; + bool m_bCanBindCommands; // Only changed by cPluginManager + + PluginLanguage m_Language; + std::vector< CommandStruct > m_Commands; + std::string m_Name; + int m_Version; +}; //tolua_export + + + + |