Cuberite
A lightweight, fast and extensible game server for Minecraft
PluginManager.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 
5 #include "../Defines.h"
6 #include "../FunctionRef.h"
7 
8 
9 
10 
11 
12 // fwd:
15 class cChunkDesc;
16 class cClientHandle;
18 class cCraftingGrid;
19 class cCraftingRecipe;
20 class cEntity;
21 class cHopperEntity;
22 class cItems;
23 class cMonster;
24 class cPickup;
25 class cPlayer;
26 class cPlugin;
27 class cProjectileEntity;
28 class cWindow;
29 class cWorld;
31 class cDeadlockDetect;
33 
34 typedef std::shared_ptr<cPlugin> cPluginPtr;
35 typedef std::vector<cPluginPtr> cPluginPtrs;
36 
37 
38 
39 
40 
41 // tolua_begin
43 {
44 public:
45 
47  {
53  } ;
54 
55 
58  {
61 
64 
67 
71 
75  };
76 
77 
79  {
149 
150  // tolua_end
151 
152  // Note that if a hook type is added, it may need processing in cPlugin::CanAddHook() descendants,
153  // and it definitely needs adding in cPluginLua::GetHookFnName() !
154 
155  // Keep these two as the last items, they are used for validity checking and get their values automagically
158  } ; // tolua_export
159 
160 
163  {
164  public:
166 
170  virtual bool Command(const AString & a_Command, const cPlugin * a_Plugin, const AString & a_Permission, const AString & a_HelpString) = 0;
171  } ;
172 
173 
176  {
177  public:
178  // Force a virtual destructor in descendants
179  virtual ~cCommandHandler() {}
180 
186  virtual bool ExecuteCommand(
187  const AStringVector & a_Split,
188  cPlayer * a_Player,
189  const AString & a_Command,
190  cCommandOutputCallback * a_Output = nullptr
191  ) = 0;
192  };
193 
194  typedef std::shared_ptr<cCommandHandler> cCommandHandlerPtr;
195 
196 
199 
200  typedef std::list<cPlugin *> PluginList;
201 
202 
204  void Tick(float a_Dt);
205 
207  static cPluginManager * Get(void); // tolua_export
208 
211  void RefreshPluginList(); // tolua_export
212 
214  void ReloadPlugins(); // tolua_export
215 
218  void AddHook(cPlugin * a_Plugin, int a_HookType);
219 
221  size_t GetNumPlugins() const; // tolua_export
222 
224  size_t GetNumLoadedPlugins(void) const; // tolua_export
225 
226  // Calls for individual hooks. Each returns false if the action is to continue or true if the plugin wants to abort
227  bool CallHookBlockSpread (cWorld & a_World, int a_BlockX, int a_BlockY, int a_BlockZ, eSpreadSource a_Source);
228  bool CallHookBlockToPickups (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);
229  bool CallHookBrewingCompleting (cWorld & a_World, cBrewingstandEntity & a_Brewingstand);
230  bool CallHookBrewingCompleted (cWorld & a_World, cBrewingstandEntity & a_Brewingstand);
231  bool CallHookChat (cPlayer & a_Player, AString & a_Message);
232  bool CallHookChunkAvailable (cWorld & a_World, int a_ChunkX, int a_ChunkZ);
233  bool CallHookChunkGenerated (cWorld & a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc);
234  bool CallHookChunkGenerating (cWorld & a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc);
235  bool CallHookChunkUnloaded (cWorld & a_World, int a_ChunkX, int a_ChunkZ);
236  bool CallHookChunkUnloading (cWorld & a_World, int a_ChunkX, int a_ChunkZ);
237  bool CallHookCollectingPickup (cPlayer & a_Player, cPickup & a_Pickup);
238  bool CallHookCraftingNoRecipe (cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe & a_Recipe);
239  bool CallHookDisconnect (cClientHandle & a_Client, const AString & a_Reason);
240  bool CallHookEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier);
241  bool CallHookEntityTeleport (cEntity & a_Entity, const Vector3d & a_OldPosition, const Vector3d & a_NewPosition);
242  bool CallHookEntityChangingWorld (cEntity & a_Entity, cWorld & a_World);
243  bool CallHookEntityChangedWorld (cEntity & a_Entity, cWorld & a_World);
244  bool CallHookExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split, const AString & a_EntireCommand, CommandResult & a_Result); // If a_Player == nullptr, it is a console cmd
245  bool CallHookExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData);
246  bool CallHookExploding (cWorld & a_World, double & a_ExplosionSize, bool & a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData);
247  bool CallHookHandshake (cClientHandle & a_ClientHandle, const AString & a_Username);
248  bool CallHookHopperPullingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_DstSlotNum, cBlockEntityWithItems & a_SrcEntity, int a_SrcSlotNum);
249  bool CallHookHopperPushingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems & a_DstEntity, int a_DstSlotNum);
250  bool CallHookKilled (cEntity & a_Victim, TakeDamageInfo & a_TDI, AString & a_DeathMessage);
251  bool CallHookKilling (cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI);
252  bool CallHookLogin (cClientHandle & a_Client, UInt32 a_ProtocolVersion, const AString & a_Username);
253  bool CallHookLoginForge (cClientHandle & a_Client, AStringMap & a_Mods);
254  bool CallHookPlayerAnimation (cPlayer & a_Player, int a_Animation);
255  bool CallHookPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
256  bool CallHookPlayerBrokenBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
257  bool CallHookPlayerDestroyed (cPlayer & a_Player);
258  bool CallHookPlayerEating (cPlayer & a_Player);
259  bool CallHookPlayerFished (cPlayer & a_Player, const cItems & a_Reward);
260  bool CallHookPlayerFishing (cPlayer & a_Player, cItems a_Reward);
261  bool CallHookPlayerFoodLevelChange (cPlayer & a_Player, int a_NewFoodLevel);
262  bool CallHookPlayerJoined (cPlayer & a_Player);
263  bool CallHookPlayerLeftClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status);
264  bool CallHookPlayerMoving (cPlayer & a_Player, const Vector3d & a_OldPosition, const Vector3d & a_NewPosition);
265  bool CallHookPlayerOpeningWindow (cPlayer & a_Player, cWindow & a_Window);
266  bool CallHookPlayerPlacedBlock (cPlayer & a_Player, const sSetBlock & a_BlockChange);
267  bool CallHookPlayerPlacingBlock (cPlayer & a_Player, const sSetBlock & a_BlockChange);
268  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);
269  bool CallHookPlayerRightClickingEntity(cPlayer & a_Player, cEntity & a_Entity);
270  bool CallHookPlayerShooting (cPlayer & a_Player);
271  bool CallHookPlayerSpawned (cPlayer & a_Player);
272  bool CallHookPlayerTossingItem (cPlayer & a_Player);
273  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);
274  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);
275  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);
276  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);
277  bool CallHookPluginMessage (cClientHandle & a_Client, const AString & a_Channel, const AString & a_Message);
278  bool CallHookPluginsLoaded (void);
279  bool CallHookPostCrafting (cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe & a_Recipe);
280  bool CallHookPreCrafting (cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe & a_Recipe);
281  bool CallHookProjectileHitBlock (cProjectileEntity & a_Projectile, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Face, const Vector3d & a_BlockHitPos);
282  bool CallHookProjectileHitEntity (cProjectileEntity & a_Projectile, cEntity & a_HitEntity);
283  bool CallHookServerPing (cClientHandle & a_ClientHandle, AString & a_ServerDescription, int & a_OnlinePlayersCount, int & a_MaxPlayersCount, AString & a_Favicon);
284  bool CallHookSpawnedEntity (cWorld & a_World, cEntity & a_Entity);
285  bool CallHookSpawnedMonster (cWorld & a_World, cMonster & a_Monster);
286  bool CallHookSpawningEntity (cWorld & a_World, cEntity & a_Entity);
287  bool CallHookSpawningMonster (cWorld & a_World, cMonster & a_Monster);
288  bool CallHookTakeDamage (cEntity & a_Receiver, TakeDamageInfo & a_TDI);
289  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);
290  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);
291  bool CallHookWeatherChanged (cWorld & a_World);
292  bool CallHookWeatherChanging (cWorld & a_World, eWeather & a_NewWeather);
293  bool CallHookWorldStarted (cWorld & a_World);
294  bool CallHookWorldTick (cWorld & a_World, std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_LastTickDurationMSec);
295 
298  void UnloadPlugin(const AString & a_PluginFolder); // tolua_export
299 
302  bool LoadPlugin(const AString & a_PluginFolder); // tolua_export
303 
305  void RemoveHooks(cPlugin * a_Plugin);
306 
308  void RemovePlugin(const AString & a_PluginName);
309 
311  void RemovePluginCommands(cPlugin * a_Plugin);
312 
314  bool IsPluginLoaded(const AString & a_PluginName); // tolua_export
315 
319  bool BindCommand(
320  const AString & a_Command,
321  cPlugin * a_Plugin,
322  cCommandHandlerPtr a_Handler,
323  const AString & a_Permission,
324  const AString & a_HelpString
325  );
326 
328  bool ForEachCommand(cCommandEnumCallback & a_Callback); // Exported in ManualBindings.cpp
329 
331  bool IsCommandBound(const AString & a_Command); // tolua_export
332 
334  AString GetCommandPermission(const AString & a_Command); // tolua_export
335 
337  CommandResult ExecuteCommand(cPlayer & a_Player, const AString & a_Command); // tolua_export
338 
340  CommandResult ForceExecuteCommand(cPlayer & a_Player, const AString & a_Command); // tolua_export
341 
343  void RemovePluginConsoleCommands(cPlugin * a_Plugin);
344 
348  bool BindConsoleCommand(
349  const AString & a_Command,
350  cPlugin * a_Plugin,
351  cCommandHandlerPtr a_Handler,
352  const AString & a_HelpString
353  );
354 
356  bool ForEachConsoleCommand(cCommandEnumCallback & a_Callback); // Exported in ManualBindings.cpp
357 
359  bool IsConsoleCommandBound(const AString & a_Command); // tolua_export
360 
364  bool ExecuteConsoleCommand(const AStringVector & a_Split, cCommandOutputCallback & a_Output, const AString & a_Command);
365 
369  void TabCompleteCommand(const AString & a_Text, AStringVector & a_Results, cPlayer * a_Player);
370 
372  static bool IsValidHookType(int a_HookType);
373 
376  bool DoWithPlugin(const AString & a_PluginName, cPluginCallback a_Callback);
377 
380  bool ForEachPlugin(cPluginCallback a_Callback);
381 
383  AString GetPluginFolderName(const AString & a_PluginName); // tolua_export
384 
387  static AString GetPluginsPath(void) { return FILE_IO_PREFIX "Plugins"; } // tolua_export
388 
389 private:
390  friend class cRoot;
391 
393  {
394  public:
396  AString m_Permission; // Not used for console commands
398  cCommandHandlerPtr m_Handler;
399  } ;
400 
401  typedef std::map<int, cPluginManager::PluginList> HookMap;
402  typedef std::map<AString, cCommandReg> CommandMap;
403 
404 
409 
412 
415 
416  HookMap m_Hooks;
417  CommandMap m_Commands;
418  CommandMap m_ConsoleCommands;
419 
422 
425 
426 
427  cPluginManager(cDeadlockDetect & a_DeadlockDetect);
428  virtual ~cPluginManager();
429 
431  void ReloadPluginsNow(void);
432 
435 
437  void UnloadPluginsNow(void);
438 
441 
443  CommandResult HandleCommand(cPlayer & a_Player, const AString & a_Command, bool a_ShouldCheckPermissions);
444 
447 
451  template <typename HookFunction>
452  bool GenericCallHook(PluginHook a_HookName, HookFunction a_HookFunction);
453 } ; // tolua_export
454 
455 
456 
457 
bool CallHookExploded(cWorld &a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void *a_SourceData)
void RemoveHooks(cPlugin *a_Plugin)
Removes all hooks the specified plugin has registered.
bool CallHookBlockSpread(cWorld &a_World, int a_BlockX, int a_BlockY, int a_BlockZ, eSpreadSource a_Source)
void RefreshPluginList()
Refreshes the m_Plugins list based on the current contents of the Plugins folder. ...
bool CallHookProjectileHitEntity(cProjectileEntity &a_Projectile, cEntity &a_HitEntity)
bool CallHookPlayerOpeningWindow(cPlayer &a_Player, cWindow &a_Window)
bool CallHookPlayerFoodLevelChange(cPlayer &a_Player, int a_NewFoodLevel)
void RemovePluginConsoleCommands(cPlugin *a_Plugin)
Removes all console command bindings that the specified plugin has made.
eWeather
Definition: Defines.h:151
bool CallHookBlockToPickups(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)
bool CallHookPlayerFished(cPlayer &a_Player, const cItems &a_Reward)
bool CallHookPluginMessage(cClientHandle &a_Client, const AString &a_Channel, const AString &a_Message)
std::map< AString, cCommandReg > CommandMap
bool CallHookDisconnect(cClientHandle &a_Client, const AString &a_Reason)
void UnloadPlugin(const AString &a_PluginFolder)
Queues the specified plugin to be unloaded in the next call to Tick().
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)
Interface that must be provided by any class that implements a command handler, either in-game or con...
void AddHook(cPlugin *a_Plugin, int a_HookType)
Adds the plugin to the list of plugins called for the specified hook type.
bool CallHookCraftingNoRecipe(cPlayer &a_Player, cCraftingGrid &a_Grid, cCraftingRecipe &a_Recipe)
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:42
virtual ~cPluginManager()
ePluginStatus
Defines the status of a single plugin - whether it is loaded, disabled or errored.
Definition: PluginManager.h:57
#define FILE_IO_PREFIX
Definition: Globals.h:196
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 CallHookPlayerLeftClick(cPlayer &a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status)
bool IsConsoleCommandBound(const AString &a_Command)
Returns true if the console command is in the command map.
void ReloadPlugins()
Schedules a reload of the plugins to happen within the next call to Tick().
AStringVector GetFoldersToLoad(cSettingsRepositoryInterface &a_Settings)
Returns the folders that are specified in the settings ini to load plugins from.
size_t GetNumLoadedPlugins(void) const
Returns the number of plugins that are psLoaded.
bool CallHookWeatherChanging(cWorld &a_World, eWeather &a_NewWeather)
Definition: Player.h:27
bool BindCommand(const AString &a_Command, cPlugin *a_Plugin, cCommandHandlerPtr a_Handler, const AString &a_Permission, const AString &a_HelpString)
Binds a command to the specified handler.
cDeadlockDetect & m_DeadlockDetect
The deadlock detect in which all plugins should track their CSs.
void TabCompleteCommand(const AString &a_Text, AStringVector &a_Results, cPlayer *a_Player)
Appends all commands beginning with a_Text (case-insensitive) into a_Results.
static bool IsValidHookType(int a_HookType)
Returns true if the specified hook type is within the allowed range.
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)
void UnloadPluginsNow(void)
Unloads all plugins.
void RemovePlugin(const AString &a_PluginName)
Removes the plugin of the specified name from the internal structures and deletes its object...
bool CallHookServerPing(cClientHandle &a_ClientHandle, AString &a_ServerDescription, int &a_OnlinePlayersCount, int &a_MaxPlayersCount, AString &a_Favicon)
bool CallHookEntityChangedWorld(cEntity &a_Entity, cWorld &a_World)
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
Definition: ChunkDef.h:45
bool BindConsoleCommand(const AString &a_Command, cPlugin *a_Plugin, cCommandHandlerPtr a_Handler, const AString &a_HelpString)
Binds a console command to the specified handler.
Definition: Pickup.h:18
bool CallHookKilled(cEntity &a_Victim, TakeDamageInfo &a_TDI, AString &a_DeathMessage)
bool CallHookHopperPushingItem(cWorld &a_World, cHopperEntity &a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems &a_DstEntity, int a_DstSlotNum)
bool CallHookBrewingCompleting(cWorld &a_World, cBrewingstandEntity &a_Brewingstand)
bool CallHookSpawningMonster(cWorld &a_World, cMonster &a_Monster)
static cPluginManager * Get(void)
Returns the instance of the Plugin Manager (there is only ever one)
bool LoadPlugin(const AString &a_PluginFolder)
Loads the plugin from the specified plugin folder.
bool CallHookPlayerAnimation(cPlayer &a_Player, int a_Animation)
bool CallHookEntityChangingWorld(cEntity &a_Entity, cWorld &a_World)
void RemovePluginCommands(cPlugin *a_Plugin)
Removes all command bindings that the specified plugin has made.
bool CallHookChunkUnloading(cWorld &a_World, int a_ChunkX, int a_ChunkZ)
void Tick(float a_Dt)
Called each tick, calls the plugins&#39; OnTick hook, as well as processes plugin events (addition...
bool CallHookChunkGenerated(cWorld &a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc *a_ChunkDesc)
bool CallHookSpawnedEntity(cWorld &a_World, cEntity &a_Entity)
AString GetPluginFolderName(const AString &a_PluginName)
Returns the name of the folder (cPlugin::GetFolderName()) from which the specified plugin was loaded...
bool CallHookPlayerRightClickingEntity(cPlayer &a_Player, cEntity &a_Entity)
std::vector< AString > AStringVector
Definition: StringUtils.h:14
bool DoWithPlugin(const AString &a_PluginName, cPluginCallback a_Callback)
Calls the specified callback with the plugin object of the specified plugin.
bool CallHookPreCrafting(cPlayer &a_Player, cCraftingGrid &a_Grid, cCraftingRecipe &a_Recipe)
bool CallHookTakeDamage(cEntity &a_Receiver, TakeDamageInfo &a_TDI)
bool CallHookPlayerPlacingBlock(cPlayer &a_Player, const sSetBlock &a_BlockChange)
bool CallHookExecuteCommand(cPlayer *a_Player, const AStringVector &a_Split, const AString &a_EntireCommand, CommandResult &a_Result)
Definition: World.h:65
bool CallHookHopperPullingItem(cWorld &a_World, cHopperEntity &a_Hopper, int a_DstSlotNum, cBlockEntityWithItems &a_SrcEntity, int a_SrcSlotNum)
bool CallHookEntityAddEffect(cEntity &a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier)
AString GetCommandPermission(const AString &a_Command)
Returns the permission needed for the specified command; empty string if command not found...
bool CallHookPlayerDestroyed(cPlayer &a_Player)
bool CallHookChunkAvailable(cWorld &a_World, int a_ChunkX, int a_ChunkZ)
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 CallHookPlayerTossingItem(cPlayer &a_Player)
bool CallHookPlayerPlacedBlock(cPlayer &a_Player, const sSetBlock &a_BlockChange)
CommandResult ExecuteCommand(cPlayer &a_Player, const AString &a_Command)
Executes the command, as if it was requested by a_Player.
std::shared_ptr< cCommandHandler > cCommandHandlerPtr
bool CallHookPlayerSpawned(cPlayer &a_Player)
std::map< int, cPluginManager::PluginList > HookMap
bool IsCommandBound(const AString &a_Command)
Returns true if the command is in the command map.
std::map< AString, AString > AStringMap
A string dictionary, used for key-value pairs.
Definition: StringUtils.h:18
bool m_bReloadPlugins
If set to true, all the plugins will be reloaded within the next call to Tick().
void InsertDefaultPlugins(cSettingsRepositoryInterface &a_Settings)
Handles writing default plugins if &#39;Plugins&#39; key not found using a settings repo expected to be intia...
bool CallHookKilling(cEntity &a_Victim, cEntity *a_Killer, TakeDamageInfo &a_TDI)
bool ExecuteConsoleCommand(const AStringVector &a_Split, cCommandOutputCallback &a_Output, const AString &a_Command)
Executes the command split into a_Split, as if it was given on the console.
void ReloadPluginsNow(void)
Reloads all plugins, defaulting to settings.ini for settings location.
bool CallHookPlayerShooting(cPlayer &a_Player)
Definition: Plugin.h:19
cCommandHandlerPtr m_Handler
The root of the object hierarchy.
Definition: Root.h:48
bool CallHookWorldStarted(cWorld &a_World)
cCriticalSection m_CSPluginsToUnload
Protects m_PluginsToUnload against multithreaded access.
size_t GetNumPlugins() const
Returns the number of all plugins in m_Plugins (includes disabled, unloaded and errored plugins)...
The plugin is enabled in settings.ini but has failed to load.
Definition: PluginManager.h:70
eExplosionSource
The source of an explosion.
Definition: BlockID.h:1202
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 CallHookPlayerJoined(cPlayer &a_Player)
static AString GetPluginsPath(void)
Returns the path where individual plugins&#39; folders are expected.
std::string AString
Definition: StringUtils.h:13
eBlockFace
Block face constants, used in PlayerDigging and PlayerBlockPlacement packets and bbox collision calc...
Definition: Defines.h:29
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 CallHookLoginForge(cClientHandle &a_Client, AStringMap &a_Mods)
bool CallHookSpawningEntity(cWorld &a_World, cEntity &a_Entity)
std::shared_ptr< cPlugin > cPluginPtr
Definition: PluginManager.h:32
bool CallHookExploding(cWorld &a_World, double &a_ExplosionSize, bool &a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void *a_SourceData)
cPluginManager(cDeadlockDetect &a_DeadlockDetect)
std::vector< cPluginPtr > cPluginPtrs
Definition: PluginManager.h:35
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)
CommandResult ForceExecuteCommand(cPlayer &a_Player, const AString &a_Command)
Executes the command, as if it was requested by a_Player.
CommandMap m_Commands
bool CallHookEntityTeleport(cEntity &a_Entity, const Vector3d &a_OldPosition, const Vector3d &a_NewPosition)
Definition: Entity.h:73
bool CallHookPlayerFishing(cPlayer &a_Player, cItems a_Reward)
bool CallHookPlayerBreakingBlock(cPlayer &a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
bool CallHookWeatherChanged(cWorld &a_World)
The plugin is enabled in settings.ini but has been unloaded (by a command).
Definition: PluginManager.h:66
bool CallHookPostCrafting(cPlayer &a_Player, cCraftingGrid &a_Grid, cCraftingRecipe &a_Recipe)
bool CallHookPlayerEating(cPlayer &a_Player)
bool CallHookBrewingCompleted(cWorld &a_World, cBrewingstandEntity &a_Brewingstand)
unsigned int UInt32
Definition: Globals.h:113
Represents a UI window.
Definition: Window.h:53
bool GenericCallHook(PluginHook a_HookName, HookFunction a_HookFunction)
Calls a_HookFunction on each plugin registered to the hook HookName.
bool CallHookPlayerMoving(cPlayer &a_Player, const Vector3d &a_OldPosition, const Vector3d &a_NewPosition)
cPluginPtrs m_Plugins
All plugins that have been found in the Plugins folder.
CommandMap m_ConsoleCommands
bool CallHookChunkUnloaded(cWorld &a_World, int a_ChunkX, int a_ChunkZ)
bool CallHookWorldTick(cWorld &a_World, std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_LastTickDurationMSec)
bool CallHookProjectileHitBlock(cProjectileEntity &a_Projectile, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Face, const Vector3d &a_BlockHitPos)
bool CallHookHandshake(cClientHandle &a_ClientHandle, const AString &a_Username)
bool ForEachConsoleCommand(cCommandEnumCallback &a_Callback)
Calls a_Callback for each bound console command, returns true if all commands were enumerated...
The plugin has been loaded before, but after a folder refresh it is no longer present.
Definition: PluginManager.h:74
bool IsPluginLoaded(const AString &a_PluginName)
Returns true if the specified plugin is loaded.
bool CallHookCollectingPickup(cPlayer &a_Player, cPickup &a_Pickup)
AStringVector m_PluginsToUnload
FolderNames of plugins that should be unloaded.
Interface for a callback that receives command output The Out() function is called for any output the...
Definition: CommandOutput.h:13
virtual bool Command(const AString &a_Command, const cPlugin *a_Plugin, const AString &a_Permission, const AString &a_HelpString)=0
Called for each command; return true to abort enumeration For console commands, a_Permission is not u...
eSpreadSource
Definition: BlockID.h:1231
bool CallHookChunkGenerating(cWorld &a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc *a_ChunkDesc)
Definition: Item.h:36
bool CallHookSpawnedMonster(cWorld &a_World, cMonster &a_Monster)
Used as a callback for enumerating bound commands.
std::list< cPlugin * > PluginList
bool CallHookPlayerBrokenBlock(cPlayer &a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
The plugin has been loaded successfully.
Definition: PluginManager.h:60
bool CallHookLogin(cClientHandle &a_Client, UInt32 a_ProtocolVersion, const AString &a_Username)
bool CallHookPluginsLoaded(void)
The plugin is disabled in settings.ini.
Definition: PluginManager.h:63
bool ForEachCommand(cCommandEnumCallback &a_Callback)
Calls a_Callback for each bound command, returns true if all commands were enumerated.
This class bridges a vector of cItem for safe access via Lua.
Definition: Item.h:234
bool ForEachPlugin(cPluginCallback a_Callback)
Calls the specified callback for each plugin in m_Plugins.
bool CallHookChat(cPlayer &a_Player, AString &a_Message)
CommandResult HandleCommand(cPlayer &a_Player, const AString &a_Command, bool a_ShouldCheckPermissions)
Tries to match a_Command to the internal table of commands, if a match is found, the corresponding pl...