diff options
author | faketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2011-10-03 20:41:19 +0200 |
---|---|---|
committer | faketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2011-10-03 20:41:19 +0200 |
commit | 386d58b5862d8b76925c6523721594887606e82a (patch) | |
tree | ef073e7a843f4b75a4008d4b7383f7cdf08ceee5 /source/cPlugin.h | |
parent | Visual Studio 2010 solution and project files (diff) | |
download | cuberite-386d58b5862d8b76925c6523721594887606e82a.tar cuberite-386d58b5862d8b76925c6523721594887606e82a.tar.gz cuberite-386d58b5862d8b76925c6523721594887606e82a.tar.bz2 cuberite-386d58b5862d8b76925c6523721594887606e82a.tar.lz cuberite-386d58b5862d8b76925c6523721594887606e82a.tar.xz cuberite-386d58b5862d8b76925c6523721594887606e82a.tar.zst cuberite-386d58b5862d8b76925c6523721594887606e82a.zip |
Diffstat (limited to '')
-rw-r--r-- | source/cPlugin.h | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/source/cPlugin.h b/source/cPlugin.h new file mode 100644 index 000000000..6c38871f3 --- /dev/null +++ b/source/cPlugin.h @@ -0,0 +1,76 @@ +#pragma once
+
+#include "MemoryLeak.h"
+
+#include <vector>
+#include <string>
+
+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;
+struct TakeDamageInfo;
+
+// 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( std::string 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( std::string 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; }
+
+ // Accessors
+ std::string GetName() const { return m_Name; }
+ void SetName( std::string 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 <<
+
+private:
+ std::vector< CommandStruct > m_Commands;
+ std::string m_Name;
+ int m_Version;
+}; //tolua_export
|