Cuberite
A lightweight, fast and extensible game server for Minecraft
PluginLua.h
Go to the documentation of this file.
1 
2 // PluginLua.h
3 
4 // Declares the cPluginLua class representing a plugin written in Lua
5 
6 
7 
8 
9 
10 #pragma once
11 
12 #include "Plugin.h"
13 #include "LuaState.h"
14 
15 // Names for the global variables through which the plugin is identified in its LuaState
16 #define LUA_PLUGIN_INSTANCE_VAR_NAME "_CuberiteInternal_PluginInstance"
17 
18 
19 
20 
21 // tolua_begin
22 class cPluginLua:
23  public cPlugin
24 {
25  // tolua_end
26 
27  using Super = cPlugin;
28 
29 public:
30 
38  class cOperation
39  {
40  public:
41  cOperation(cPluginLua & a_Plugin) :
42  m_Plugin(a_Plugin),
43  m_Lock(a_Plugin.m_LuaState)
44  {
45  }
46 
48 
49  protected:
51 
54  } ;
55 
56 
57 
58  cPluginLua(const AString & a_PluginDirectory, cDeadlockDetect & a_DeadlockDetect);
59  virtual ~cPluginLua() override;
60 
61  virtual void OnDisable(void) override;
62  virtual bool Load(void) override;
63  virtual void Unload(void) override;
64 
65  virtual void Tick(float a_Dt) override;
66 
67  virtual bool OnBlockSpread (cWorld & a_World, int a_BlockX, int a_BlockY, int a_BlockZ, eSpreadSource a_Source) override;
68  virtual bool OnBlockToPickups (cWorld & a_World, Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, const cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool, cItems & a_Pickups) override;
69  virtual bool OnBrewingCompleting (cWorld & a_World, cBrewingstandEntity & a_BrewingstandEntity) override;
70  virtual bool OnBrewingCompleted (cWorld & a_World, cBrewingstandEntity & a_BrewingstandEntity) override;
71  virtual bool OnChat (cPlayer & a_Player, AString & a_Message) override;
72  virtual bool OnChunkAvailable (cWorld & a_World, int a_ChunkX, int a_ChunkZ) override;
73  virtual bool OnChunkGenerated (cWorld & a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc) override;
74  virtual bool OnChunkGenerating (cWorld & a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc) override;
75  virtual bool OnChunkUnloaded (cWorld & a_World, int a_ChunkX, int a_ChunkZ) override;
76  virtual bool OnChunkUnloading (cWorld & a_World, int a_ChunkX, int a_ChunkZ) override;
77  virtual bool OnCollectingPickup (cPlayer & a_Player, cPickup & a_Pickup) override;
78  virtual bool OnCraftingNoRecipe (cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe & a_Recipe) override;
79  virtual bool OnDisconnect (cClientHandle & a_Client, const AString & a_Reason) override;
80  virtual bool OnEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier) override;
81  virtual bool OnEntityChangingWorld (cEntity & a_Entity, cWorld & a_World) override;
82  virtual bool OnEntityChangedWorld (cEntity & a_Entity, cWorld & a_World) override;
83  virtual bool OnExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split, const AString & a_EntireCommand, cPluginManager::CommandResult & a_Result) override;
84  virtual bool OnExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) override;
85  virtual bool OnExploding (cWorld & a_World, double & a_ExplosionSize, bool & a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) override;
86  virtual bool OnHandshake (cClientHandle & a_Client, const AString & a_Username) override;
87  virtual bool OnHopperPullingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_DstSlotNum, cBlockEntityWithItems & a_SrcEntity, int a_SrcSlotNum) override;
88  virtual bool OnHopperPushingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems & a_DstEntity, int a_DstSlotNum) override;
89  virtual bool OnDropSpense (cWorld & a_World, cDropSpenserEntity & a_DropSpenser, int a_SlotNum) override;
90  virtual bool OnKilled (cEntity & a_Victim, TakeDamageInfo & a_TDI, AString & a_DeathMessage) override;
91  virtual bool OnKilling (cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI) override;
92  virtual bool OnLogin (cClientHandle & a_Client, UInt32 a_ProtocolVersion, const AString & a_Username) override;
93  virtual bool OnLoginForge (cClientHandle & a_Client, const AStringMap & a_Mods) override;
94  virtual bool OnPlayerAnimation (cPlayer & a_Player, int a_Animation) override;
95  virtual bool OnPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override;
96  virtual bool OnPlayerBrokenBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override;
97  virtual bool OnPlayerDestroyed (cPlayer & a_Player) override;
98  virtual bool OnPlayerEating (cPlayer & a_Player) override;
99  virtual bool OnPlayerFished (cPlayer & a_Player, const cItems & a_Reward, const int ExperienceAmount) override;
100  virtual bool OnPlayerFishing (cPlayer & a_Player, cItems & a_Reward, int & ExperienceAmount) override;
101  virtual bool OnPlayerFoodLevelChange (cPlayer & a_Player, int a_NewFoodLevel) override;
102  virtual bool OnPlayerJoined (cPlayer & a_Player) override;
103  virtual bool OnPlayerLeftClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, char a_Status) override;
104  virtual bool OnPlayerMoving (cPlayer & a_Player, const Vector3d & a_OldPosition, const Vector3d & a_NewPosition, bool a_PreviousIsOnGround) override;
105  virtual bool OnPlayerOpeningWindow (cPlayer & a_Player, cWindow & a_Window) override;
106  virtual bool OnPlayerPlacedBlock (cPlayer & a_Player, const sSetBlock & a_BlockChange) override;
107  virtual bool OnPlayerPlacingBlock (cPlayer & a_Player, const sSetBlock & a_BlockChange) override;
108  virtual bool OnPlayerCrouched (cPlayer & a_Player) override;
109  virtual bool OnPlayerRightClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override;
110  virtual bool OnPlayerRightClickingEntity(cPlayer & a_Player, cEntity & a_Entity) override;
111  virtual bool OnPlayerShooting (cPlayer & a_Player) override;
112  virtual bool OnPlayerSpawned (cPlayer & a_Player) override;
113  virtual bool OnEntityTeleport (cEntity & a_Entity, const Vector3d & a_OldPosition, const Vector3d & a_NewPosition) override;
114  virtual bool OnPlayerTossingItem (cPlayer & a_Player) override;
115  virtual bool OnPlayerUsedBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override;
116  virtual bool OnPlayerUsedItem (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override;
117  virtual bool OnPlayerUsingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override;
118  virtual bool OnPlayerUsingItem (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override;
119  virtual bool OnPluginMessage (cClientHandle & a_Client, const AString & a_Channel, ContiguousByteBufferView a_Message) override;
120  virtual bool OnPluginsLoaded (void) override;
121  virtual bool OnPostCrafting (cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe & a_Recipe) override;
122  virtual bool OnPreCrafting (cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe & a_Recipe) override;
123  virtual bool OnProjectileHitBlock (cProjectileEntity & a_Projectile, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Face, const Vector3d & a_BlockHitPos) override;
124  virtual bool OnProjectileHitEntity (cProjectileEntity & a_Projectile, cEntity & a_HitEntity) override;
125  virtual bool OnServerPing (cClientHandle & a_ClientHandle, AString & a_ServerDescription, int & a_OnlinePlayersCount, int & a_MaxPlayersCount, AString & a_Favicon) override;
126  virtual bool OnSpawnedEntity (cWorld & a_World, cEntity & a_Entity) override;
127  virtual bool OnSpawnedMonster (cWorld & a_World, cMonster & a_Monster) override;
128  virtual bool OnSpawningEntity (cWorld & a_World, cEntity & a_Entity) override;
129  virtual bool OnSpawningMonster (cWorld & a_World, cMonster & a_Monster) override;
130  virtual bool OnTakeDamage (cEntity & a_Receiver, TakeDamageInfo & a_TakeDamageInfo) override;
131  virtual bool OnUpdatedSign (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) override;
132  virtual bool OnUpdatingSign (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) override;
133  virtual bool OnWeatherChanged (cWorld & a_World) override;
134  virtual bool OnWeatherChanging (cWorld & a_World, eWeather & a_NewWeather) override;
135  virtual bool OnWorldStarted (cWorld & a_World) override;
136  virtual bool OnWorldTick (cWorld & a_World, std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_LastTickDurationMSec) override;
137 
139  bool CanAddOldStyleHook(int a_HookType);
140 
142  static const char * GetHookFnName(int a_HookType);
143 
146  bool AddHookCallback(int a_HookType, cLuaState::cCallbackPtr && a_Callback);
147 
152  const AString & a_FunctionName,
153  cLuaState & a_ForeignState,
154  int a_ParamStart,
155  int a_ParamEnd
156  );
157 
159  template <typename FnT, typename... Args>
160  bool Call(FnT a_Fn, Args && ... a_Args)
161  {
162  return cOperation(*this)().Call(a_Fn, a_Args...);
163  }
164 
165 protected:
167  typedef std::vector<cLuaState::cCallbackPtr> cLuaCallbacks;
168 
170  typedef std::map<int, cLuaCallbacks> cHookMap;
171 
172 
175 
178 
181 
182 
184  void Close(void);
185 
187  void ClearWebTabs(void);
188 
192  template <typename... Args>
193  bool CallSimpleHooks(int a_HookType, Args && ... a_Args)
194  {
195  cOperation op(*this);
196  auto & hooks = m_HookMap[a_HookType];
197  bool res = false;
198  for (auto & hook: hooks)
199  {
200  hook->Call(std::forward<Args>(a_Args)..., cLuaState::Return, res);
201  if (res)
202  {
203  // Hook wants to terminate the chain processing
204  return true;
205  }
206  }
207  return false;
208  }
209 }; // tolua_export
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
Definition: ChunkDef.h:44
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:41
eWeather
Definition: Defines.h:160
eExplosionSource
The source of an explosion.
Definition: Defines.h:309
eBlockFace
Block face constants, used in PlayerDigging and PlayerBlockPlacement packets and bbox collision calc.
Definition: Defines.h:38
eSpreadSource
Definition: Defines.h:339
unsigned int UInt32
Definition: Globals.h:157
std::basic_string_view< std::byte > ContiguousByteBufferView
Definition: Globals.h:376
std::vector< AString > AStringVector
Definition: StringUtils.h:12
std::string AString
Definition: StringUtils.h:11
std::map< AString, AString > AStringMap
A string dictionary, used for key-value pairs.
Definition: StringUtils.h:16
Encapsulates a Lua state and provides some syntactic sugar for common operations.
Definition: LuaState.h:56
std::unique_ptr< cCallback > cCallbackPtr
Definition: LuaState.h:326
static const cRet Return
Definition: LuaState.h:445
Provides a RAII-style locking for the LuaState.
Definition: LuaState.h:145
Definition: Plugin.h:20
cPlugin(const AString &a_FolderName)
Creates a new instance.
Definition: Plugin.cpp:10
virtual bool OnPlayerFished(cPlayer &a_Player, const cItems &a_Reward, const int ExperienceAmount) override
Definition: PluginLua.cpp:642
virtual bool OnChat(cPlayer &a_Player, AString &a_Message) override
Definition: PluginLua.cpp:272
virtual bool OnExploded(cWorld &a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void *a_SourceData) override
Definition: PluginLua.cpp:419
virtual bool OnSpawningMonster(cWorld &a_World, cMonster &a_Monster) override
Definition: PluginLua.cpp:941
virtual bool OnChunkAvailable(cWorld &a_World, int a_ChunkX, int a_ChunkZ) override
Definition: PluginLua.cpp:296
bool CanAddOldStyleHook(int a_HookType)
Returns true if the plugin contains the function for the specified hook type, using the old-style reg...
Definition: PluginLua.cpp:1053
virtual void Tick(float a_Dt) override
Definition: PluginLua.cpp:212
virtual bool OnPostCrafting(cPlayer &a_Player, cCraftingGrid &a_Grid, cCraftingRecipe &a_Recipe) override
Definition: PluginLua.cpp:854
virtual bool OnWorldStarted(cWorld &a_World) override
Definition: PluginLua.cpp:1035
virtual bool OnChunkGenerated(cWorld &a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc *a_ChunkDesc) override
Definition: PluginLua.cpp:305
virtual bool OnLogin(cClientHandle &a_Client, UInt32 a_ProtocolVersion, const AString &a_Username) override
Definition: PluginLua.cpp:570
virtual bool OnPlayerMoving(cPlayer &a_Player, const Vector3d &a_OldPosition, const Vector3d &a_NewPosition, bool a_PreviousIsOnGround) override
Definition: PluginLua.cpp:679
virtual bool OnSpawnedEntity(cWorld &a_World, cEntity &a_Entity) override
Definition: PluginLua.cpp:914
virtual bool OnPlayerDestroyed(cPlayer &a_Player) override
Definition: PluginLua.cpp:615
void Close(void)
Releases all Lua references, notifies and removes all m_Resettables[] and closes the m_LuaState.
Definition: PluginLua.cpp:60
virtual bool OnCollectingPickup(cPlayer &a_Player, cPickup &a_Pickup) override
Definition: PluginLua.cpp:341
static const char * GetHookFnName(int a_HookType)
Returns the name of Lua function that should handle the specified hook type in the older (#121) API.
Definition: PluginLua.cpp:1083
virtual bool OnKilled(cEntity &a_Victim, TakeDamageInfo &a_TDI, AString &a_DeathMessage) override
Definition: PluginLua.cpp:537
virtual ~cPluginLua() override
Definition: PluginLua.cpp:50
virtual void OnDisable(void) override
Called as the last call into the plugin before it is unloaded.
Definition: PluginLua.cpp:198
bool AddHookCallback(int a_HookType, cLuaState::cCallbackPtr &&a_Callback)
Adds a Lua callback to be called for the specified hook.
Definition: PluginLua.cpp:1160
virtual bool OnDisconnect(cClientHandle &a_Client, const AString &a_Reason) override
Definition: PluginLua.cpp:359
virtual bool OnPlayerSpawned(cPlayer &a_Player) override
Definition: PluginLua.cpp:769
virtual bool OnPreCrafting(cPlayer &a_Player, cCraftingGrid &a_Grid, cCraftingRecipe &a_Recipe) override
Definition: PluginLua.cpp:863
virtual bool OnPluginsLoaded(void) override
Definition: PluginLua.cpp:832
virtual bool OnSpawnedMonster(cWorld &a_World, cMonster &a_Monster) override
Definition: PluginLua.cpp:923
virtual bool OnPlayerRightClickingEntity(cPlayer &a_Player, cEntity &a_Entity) override
Definition: PluginLua.cpp:751
virtual bool OnKilling(cEntity &a_Victim, cEntity *a_Killer, TakeDamageInfo &a_TDI) override
Definition: PluginLua.cpp:561
virtual bool OnWeatherChanging(cWorld &a_World, eWeather &a_NewWeather) override
Definition: PluginLua.cpp:1011
std::map< int, cLuaCallbacks > cHookMap
Maps hook types into arrays of Lua function references to call for each hook type.
Definition: PluginLua.h:170
virtual bool OnServerPing(cClientHandle &a_ClientHandle, AString &a_ServerDescription, int &a_OnlinePlayersCount, int &a_MaxPlayersCount, AString &a_Favicon) override
Definition: PluginLua.cpp:890
virtual bool OnBrewingCompleting(cWorld &a_World, cBrewingstandEntity &a_BrewingstandEntity) override
Definition: PluginLua.cpp:263
int CallFunctionFromForeignState(const AString &a_FunctionName, cLuaState &a_ForeignState, int a_ParamStart, int a_ParamEnd)
Calls a function in this plugin's LuaState with parameters copied over from a_ForeignState.
Definition: PluginLua.cpp:1170
virtual bool OnExploding(cWorld &a_World, double &a_ExplosionSize, bool &a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void *a_SourceData) override
Definition: PluginLua.cpp:460
virtual bool OnPlayerJoined(cPlayer &a_Player) override
Definition: PluginLua.cpp:661
virtual bool OnHopperPushingItem(cWorld &a_World, cHopperEntity &a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems &a_DstEntity, int a_DstSlotNum) override
Definition: PluginLua.cpp:519
virtual bool OnPlayerOpeningWindow(cPlayer &a_Player, cWindow &a_Window) override
Definition: PluginLua.cpp:697
virtual bool OnPlayerAnimation(cPlayer &a_Player, int a_Animation) override
Definition: PluginLua.cpp:588
virtual bool OnPlayerUsedItem(cPlayer &a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
Definition: PluginLua.cpp:796
virtual bool OnUpdatedSign(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) override
Definition: PluginLua.cpp:959
virtual bool OnEntityChangedWorld(cEntity &a_Entity, cWorld &a_World) override
Definition: PluginLua.cpp:386
virtual bool OnPlayerBrokenBlock(cPlayer &a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override
Definition: PluginLua.cpp:606
virtual bool OnLoginForge(cClientHandle &a_Client, const AStringMap &a_Mods) override
Definition: PluginLua.cpp:579
virtual bool OnPluginMessage(cClientHandle &a_Client, const AString &a_Channel, ContiguousByteBufferView a_Message) override
Definition: PluginLua.cpp:823
virtual bool OnPlayerUsingItem(cPlayer &a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
Definition: PluginLua.cpp:814
cPluginLua(const AString &a_PluginDirectory, cDeadlockDetect &a_DeadlockDetect)
Definition: PluginLua.cpp:38
virtual bool OnHopperPullingItem(cWorld &a_World, cHopperEntity &a_Hopper, int a_DstSlotNum, cBlockEntityWithItems &a_SrcEntity, int a_SrcSlotNum) override
Definition: PluginLua.cpp:510
cLuaState m_LuaState
The plugin's Lua state.
Definition: PluginLua.h:174
virtual bool OnEntityAddEffect(cEntity &a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier) override
Definition: PluginLua.cpp:368
virtual bool OnSpawningEntity(cWorld &a_World, cEntity &a_Entity) override
Definition: PluginLua.cpp:932
virtual bool OnPlayerFoodLevelChange(cPlayer &a_Player, int a_NewFoodLevel) override
Definition: PluginLua.cpp:633
virtual bool OnProjectileHitEntity(cProjectileEntity &a_Projectile, cEntity &a_HitEntity) override
Definition: PluginLua.cpp:881
bool Call(FnT a_Fn, Args &&... a_Args)
Call a Lua function residing in the plugin.
Definition: PluginLua.h:160
virtual bool OnPlayerEating(cPlayer &a_Player) override
Definition: PluginLua.cpp:624
bool CallSimpleHooks(int a_HookType, Args &&... a_Args)
Calls a hook that has the simple format - single bool return value specifying whether the chain shoul...
Definition: PluginLua.h:193
virtual bool OnBlockToPickups(cWorld &a_World, Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, const cBlockEntity *a_BlockEntity, const cEntity *a_Digger, const cItem *a_Tool, cItems &a_Pickups) override
Definition: PluginLua.cpp:230
virtual bool OnPlayerUsedBlock(cPlayer &a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override
Definition: PluginLua.cpp:787
virtual bool OnChunkUnloading(cWorld &a_World, int a_ChunkX, int a_ChunkZ) override
Definition: PluginLua.cpp:332
virtual bool OnPlayerShooting(cPlayer &a_Player) override
Definition: PluginLua.cpp:760
virtual bool OnChunkUnloaded(cWorld &a_World, int a_ChunkX, int a_ChunkZ) override
Definition: PluginLua.cpp:323
virtual bool OnPlayerUsingBlock(cPlayer &a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override
Definition: PluginLua.cpp:805
virtual bool OnHandshake(cClientHandle &a_Client, const AString &a_Username) override
Definition: PluginLua.cpp:501
virtual bool OnEntityChangingWorld(cEntity &a_Entity, cWorld &a_World) override
Definition: PluginLua.cpp:377
virtual bool OnPlayerPlacingBlock(cPlayer &a_Player, const sSetBlock &a_BlockChange) override
Definition: PluginLua.cpp:719
virtual bool OnPlayerBreakingBlock(cPlayer &a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override
Definition: PluginLua.cpp:597
virtual bool OnEntityTeleport(cEntity &a_Entity, const Vector3d &a_OldPosition, const Vector3d &a_NewPosition) override
Definition: PluginLua.cpp:688
virtual bool OnProjectileHitBlock(cProjectileEntity &a_Projectile, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Face, const Vector3d &a_BlockHitPos) override
Definition: PluginLua.cpp:872
virtual bool OnExecuteCommand(cPlayer *a_Player, const AStringVector &a_Split, const AString &a_EntireCommand, cPluginManager::CommandResult &a_Result) override
Definition: PluginLua.cpp:395
std::vector< cLuaState::cCallbackPtr > cLuaCallbacks
Provides an array of Lua function references.
Definition: PluginLua.h:167
void ClearWebTabs(void)
Removes all WebTabs currently registered for this plugin from the WebAdmin.
Definition: PluginLua.cpp:1204
virtual bool OnCraftingNoRecipe(cPlayer &a_Player, cCraftingGrid &a_Grid, cCraftingRecipe &a_Recipe) override
Definition: PluginLua.cpp:350
virtual bool OnWeatherChanged(cWorld &a_World) override
Definition: PluginLua.cpp:1002
virtual bool OnPlayerFishing(cPlayer &a_Player, cItems &a_Reward, int &ExperienceAmount) override
Definition: PluginLua.cpp:652
virtual bool OnChunkGenerating(cWorld &a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc *a_ChunkDesc) override
Definition: PluginLua.cpp:314
virtual bool OnUpdatingSign(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) override
Definition: PluginLua.cpp:973
virtual bool OnPlayerCrouched(cPlayer &a_Player) override
Definition: PluginLua.cpp:732
virtual bool Load(void) override
Loads and initializes the plugin.
Definition: PluginLua.cpp:84
virtual bool OnPlayerLeftClick(cPlayer &a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, char a_Status) override
Definition: PluginLua.cpp:670
cDeadlockDetect & m_DeadlockDetect
The DeadlockDetect object to which the plugin's CS is tracked.
Definition: PluginLua.h:180
virtual bool OnTakeDamage(cEntity &a_Receiver, TakeDamageInfo &a_TakeDamageInfo) override
Definition: PluginLua.cpp:950
virtual bool OnBlockSpread(cWorld &a_World, int a_BlockX, int a_BlockY, int a_BlockZ, eSpreadSource a_Source) override
Calls the specified hook with the params given.
Definition: PluginLua.cpp:221
cHookMap m_HookMap
Hooks that the plugin has registered.
Definition: PluginLua.h:177
virtual bool OnPlayerPlacedBlock(cPlayer &a_Player, const sSetBlock &a_BlockChange) override
Definition: PluginLua.cpp:706
virtual bool OnWorldTick(cWorld &a_World, std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_LastTickDurationMSec) override
Definition: PluginLua.cpp:1044
virtual bool OnPlayerRightClick(cPlayer &a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
Definition: PluginLua.cpp:742
virtual void Unload(void) override
Unloads the plugin.
Definition: PluginLua.cpp:187
virtual bool OnBrewingCompleted(cWorld &a_World, cBrewingstandEntity &a_BrewingstandEntity) override
Definition: PluginLua.cpp:254
virtual bool OnDropSpense(cWorld &a_World, cDropSpenserEntity &a_DropSpenser, int a_SlotNum) override
Definition: PluginLua.cpp:528
virtual bool OnPlayerTossingItem(cPlayer &a_Player) override
Definition: PluginLua.cpp:778
A RAII-style mutex lock for accessing the internal LuaState.
Definition: PluginLua.h:39
cLuaState & operator()(void)
Definition: PluginLua.h:47
cOperation(cPluginLua &a_Plugin)
Definition: PluginLua.h:41
cPluginLua & m_Plugin
Definition: PluginLua.h:50
cLuaState::cLock m_Lock
RAII lock for the Lua state.
Definition: PluginLua.h:53
Definition: Entity.h:76
Definition: Pickup.h:20
Definition: Player.h:29
Definition: Item.h:37
This class bridges a vector of cItem for safe access via Lua.
Definition: Item.h:215
Represents a UI window.
Definition: Window.h:54
Definition: World.h:53