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 "../BlockType.h"
6 #include "../Defines.h"
7 #include "../FunctionRef.h"
8 
9 
10 
11 
12 
13 // fwd:
16 class cChunkDesc;
17 class cClientHandle;
19 class cCraftingGrid;
20 class cCraftingRecipe;
21 class cDropSpenserEntity;
22 class cEntity;
23 class cHopperEntity;
24 class cItems;
25 class cMonster;
26 class cPickup;
27 class cPlayer;
28 class cPlugin;
29 class cProjectileEntity;
30 class cWindow;
31 class cWorld;
33 class cDeadlockDetect;
34 struct TakeDamageInfo;
35 
36 typedef std::shared_ptr<cPlugin> cPluginPtr;
37 typedef std::vector<cPluginPtr> cPluginPtrs;
38 
39 
40 
41 
42 
43 // tolua_begin
45 {
46 public:
47 
49  {
55  } ;
56 
57 
60  {
63 
66 
69 
73 
77  };
78 
79 
81  {
153 
154  // tolua_end
155 
156  // Note that if a hook type is added, it may need processing in cPlugin::CanAddHook() descendants,
157  // and it definitely needs adding in cPluginLua::GetHookFnName() !
158 
159  // Keep these two as the last items, they are used for validity checking and get their values automagically
162  } ; // tolua_export
163 
164 
166  enum class PluginAction
167  {
168  Reload,
169  Unload
170  };
171 
172 
175  {
176  public:
178 
182  virtual bool Command(const AString & a_Command, const cPlugin * a_Plugin, const AString & a_Permission, const AString & a_HelpString) = 0;
183  } ;
184 
185 
188  {
189  public:
190  // Force a virtual destructor in descendants
191  virtual ~cCommandHandler() {}
192 
198  virtual bool ExecuteCommand(
199  const AStringVector & a_Split,
200  cPlayer * a_Player,
201  const AString & a_Command,
202  cCommandOutputCallback * a_Output = nullptr
203  ) = 0;
204  };
205 
206  typedef std::shared_ptr<cCommandHandler> cCommandHandlerPtr;
207 
208 
211 
212  typedef std::list<cPlugin *> PluginList;
213 
214 
216  void Tick(float a_Dt);
217 
219  static cPluginManager * Get(void); // tolua_export
220 
223  void RefreshPluginList(); // tolua_export
224 
226  void ReloadPlugins(); // tolua_export
227 
230  void AddHook(cPlugin * a_Plugin, int a_HookType);
231 
233  size_t GetNumPlugins() const; // tolua_export
234 
236  size_t GetNumLoadedPlugins(void) const; // tolua_export
237 
238  // Calls for individual hooks. Each returns false if the action is to continue or true if the plugin wants to abort
239  bool CallHookBlockSpread (cWorld & a_World, Vector3i a_BlockPos, eSpreadSource a_Source);
240  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);
241  bool CallHookBrewingCompleting (cWorld & a_World, cBrewingstandEntity & a_Brewingstand);
242  bool CallHookBrewingCompleted (cWorld & a_World, cBrewingstandEntity & a_Brewingstand);
243  bool CallHookChat (cPlayer & a_Player, AString & a_Message);
244  bool CallHookChunkAvailable (cWorld & a_World, int a_ChunkX, int a_ChunkZ);
245  bool CallHookChunkGenerated (cWorld & a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc);
246  bool CallHookChunkGenerating (cWorld & a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc);
247  bool CallHookChunkUnloaded (cWorld & a_World, int a_ChunkX, int a_ChunkZ);
248  bool CallHookChunkUnloading (cWorld & a_World, int a_ChunkX, int a_ChunkZ);
249  bool CallHookCollectingPickup (cPlayer & a_Player, cPickup & a_Pickup);
250  bool CallHookCraftingNoRecipe (cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe & a_Recipe);
251  bool CallHookDisconnect (cClientHandle & a_Client, const AString & a_Reason);
252  bool CallHookEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier);
253  bool CallHookEntityTeleport (cEntity & a_Entity, const Vector3d & a_OldPosition, const Vector3d & a_NewPosition);
254  bool CallHookEntityChangingWorld (cEntity & a_Entity, cWorld & a_World);
255  bool CallHookEntityChangedWorld (cEntity & a_Entity, cWorld & a_World);
256  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
257  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);
258  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);
259  bool CallHookHandshake (cClientHandle & a_ClientHandle, const AString & a_Username);
260  bool CallHookHopperPullingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_DstSlotNum, cBlockEntityWithItems & a_SrcEntity, int a_SrcSlotNum);
261  bool CallHookHopperPushingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems & a_DstEntity, int a_DstSlotNum);
262  bool CallHookDropSpense (cWorld & a_World, cDropSpenserEntity & a_DropSpenser, int a_SlotNum);
263  bool CallHookKilled (cEntity & a_Victim, TakeDamageInfo & a_TDI, AString & a_DeathMessage);
264  bool CallHookKilling (cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI);
265  bool CallHookLogin (cClientHandle & a_Client, UInt32 a_ProtocolVersion, const AString & a_Username);
266  bool CallHookLoginForge (cClientHandle & a_Client, AStringMap & a_Mods);
267  bool CallHookPlayerAnimation (cPlayer & a_Player, int a_Animation);
268  bool CallHookPlayerBreakingBlock (cPlayer & a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
269  bool CallHookPlayerBrokenBlock (cPlayer & a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
270  bool CallHookPlayerDestroyed (cPlayer & a_Player);
271  bool CallHookPlayerEating (cPlayer & a_Player);
272  bool CallHookPlayerFished (cPlayer & a_Player, const cItems & a_Reward, const int ExperienceAmount);
273  bool CallHookPlayerFishing (cPlayer & a_Player, cItems & a_Reward, int & ExperienceAmount);
274  bool CallHookPlayerFoodLevelChange (cPlayer & a_Player, int a_NewFoodLevel);
275  bool CallHookPlayerJoined (cPlayer & a_Player);
276  bool CallHookPlayerLeftClick (cPlayer & a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, char a_Status);
277  bool CallHookPlayerMoving (cPlayer & a_Player, const Vector3d & a_OldPosition, const Vector3d & a_NewPosition, bool a_PreviousIsOnGround);
278  bool CallHookPlayerOpeningWindow (cPlayer & a_Player, cWindow & a_Window);
279  bool CallHookPlayerPlacedBlock (cPlayer & a_Player, const sSetBlock & a_BlockChange);
280  bool CallHookPlayerPlacingBlock (cPlayer & a_Player, const sSetBlock & a_BlockChange);
281  bool CallHookPlayerCrouched (cPlayer & a_Player);
282  bool CallHookPlayerRightClick (cPlayer & a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, Vector3i a_CursorPos);
283  bool CallHookPlayerRightClickingEntity(cPlayer & a_Player, cEntity & a_Entity);
284  bool CallHookPlayerShooting (cPlayer & a_Player);
285  bool CallHookPlayerSpawned (cPlayer & a_Player);
286  bool CallHookPlayerTossingItem (cPlayer & a_Player);
287  bool CallHookPlayerUsedBlock (cPlayer & a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, Vector3i a_CursorPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
288  bool CallHookPlayerUsedItem (cPlayer & a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, Vector3i a_CursorPos);
289  bool CallHookPlayerUsingBlock (cPlayer & a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, Vector3i a_CursorPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
290  bool CallHookPlayerUsingItem (cPlayer & a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, Vector3i a_CursorPos);
291  bool CallHookPluginMessage (cClientHandle & a_Client, const AString & a_Channel, ContiguousByteBufferView a_Message);
292  bool CallHookPluginsLoaded (void);
293  bool CallHookPostCrafting (cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe & a_Recipe);
294  bool CallHookPreCrafting (cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe & a_Recipe);
295  bool CallHookProjectileHitBlock (cProjectileEntity & a_Projectile, Vector3i a_BlockPos, eBlockFace a_Face, const Vector3d & a_BlockHitPos);
296  bool CallHookProjectileHitEntity (cProjectileEntity & a_Projectile, cEntity & a_HitEntity);
297  bool CallHookServerPing (cClientHandle & a_ClientHandle, AString & a_ServerDescription, int & a_OnlinePlayersCount, int & a_MaxPlayersCount, AString & a_Favicon);
298  bool CallHookSpawnedEntity (cWorld & a_World, cEntity & a_Entity);
299  bool CallHookSpawnedMonster (cWorld & a_World, cMonster & a_Monster);
300  bool CallHookSpawningEntity (cWorld & a_World, cEntity & a_Entity);
301  bool CallHookSpawningMonster (cWorld & a_World, cMonster & a_Monster);
302  bool CallHookTakeDamage (cEntity & a_Receiver, TakeDamageInfo & a_TDI);
303  bool CallHookUpdatedSign (cWorld & a_World, Vector3i a_BlockPos, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player);
304  bool CallHookUpdatingSign (cWorld & a_World, Vector3i a_BlockPos, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4, cPlayer * a_Player);
305  bool CallHookWeatherChanged (cWorld & a_World);
306  bool CallHookWeatherChanging (cWorld & a_World, eWeather & a_NewWeather);
307  bool CallHookWorldStarted (cWorld & a_World);
308  bool CallHookWorldTick (cWorld & a_World, std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_LastTickDurationMSec);
309 
312  void UnloadPlugin(const AString & a_PluginFolder); // tolua_export
313 
316  void ReloadPlugin(const AString & a_PluginFolder); // tolua_export
317 
320  bool LoadPlugin(const AString & a_PluginFolder); // tolua_export
321 
323  void RemoveHooks(cPlugin * a_Plugin);
324 
326  void RemovePlugin(const AString & a_PluginName);
327 
329  void RemovePluginCommands(cPlugin * a_Plugin);
330 
332  bool IsPluginLoaded(const AString & a_PluginName); // tolua_export
333 
337  bool BindCommand(
338  const AString & a_Command,
339  cPlugin * a_Plugin,
340  cCommandHandlerPtr a_Handler,
341  const AString & a_Permission,
342  const AString & a_HelpString
343  );
344 
346  bool ForEachCommand(cCommandEnumCallback & a_Callback); // Exported in ManualBindings.cpp
347 
349  bool IsCommandBound(const AString & a_Command); // tolua_export
350 
352  AString GetCommandPermission(const AString & a_Command); // tolua_export
353 
355  CommandResult ExecuteCommand(cPlayer & a_Player, const AString & a_Command); // tolua_export
356 
358  CommandResult ForceExecuteCommand(cPlayer & a_Player, const AString & a_Command); // tolua_export
359 
361  void RemovePluginConsoleCommands(cPlugin * a_Plugin);
362 
366  bool BindConsoleCommand(
367  const AString & a_Command,
368  cPlugin * a_Plugin,
369  cCommandHandlerPtr a_Handler,
370  const AString & a_HelpString
371  );
372 
374  bool ForEachConsoleCommand(cCommandEnumCallback & a_Callback); // Exported in ManualBindings.cpp
375 
377  bool IsConsoleCommandBound(const AString & a_Command); // tolua_export
378 
382  bool ExecuteConsoleCommand(const AStringVector & a_Split, cCommandOutputCallback & a_Output, const AString & a_Command);
383 
387  void TabCompleteCommand(const AString & a_Text, AStringVector & a_Results, cPlayer * a_Player);
388 
390  static bool IsValidHookType(int a_HookType);
391 
394  bool DoWithPlugin(const AString & a_PluginName, cPluginCallback a_Callback);
395 
398  bool ForEachPlugin(cPluginCallback a_Callback);
399 
401  AString GetPluginFolderName(const AString & a_PluginName); // tolua_export
402 
405  static AString GetPluginsPath(void) { return "Plugins"; } // tolua_export
406 
407 private:
408  friend class cRoot;
409 
411  {
412  public:
414  AString m_Permission; // Not used for console commands
417  } ;
418 
419  typedef std::map<int, cPluginManager::PluginList> HookMap;
420  typedef std::map<AString, cCommandReg> CommandMap;
421 
422 
426  std::vector<std::pair<PluginAction, AString>> m_PluginsNeedAction;
427 
430 
433 
437 
440 
443 
444 
445  cPluginManager(cDeadlockDetect & a_DeadlockDetect);
446  virtual ~cPluginManager();
447 
449  void ReloadPluginsNow(void);
450 
453 
455  void UnloadPluginsNow(void);
456 
459 
461  CommandResult HandleCommand(cPlayer & a_Player, const AString & a_Command, bool a_ShouldCheckPermissions);
462 
465 
469  template <typename HookFunction>
470  bool GenericCallHook(PluginHook a_HookName, HookFunction a_HookFunction);
471 } ; // tolua_export
472 
473 
474 
std::shared_ptr< cPlugin > cPluginPtr
Definition: PluginManager.h:34
std::vector< cPluginPtr > cPluginPtrs
Definition: PluginManager.h:37
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
Definition: Plugin.h:20
void InsertDefaultPlugins(cSettingsRepositoryInterface &a_Settings)
Handles writing default plugins if 'Plugins' key not found using a settings repo expected to be intia...
cPluginManager(cDeadlockDetect &a_DeadlockDetect)
bool CallHookPlayerAnimation(cPlayer &a_Player, int a_Animation)
bool CallHookChunkGenerated(cWorld &a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc *a_ChunkDesc)
AString GetCommandPermission(const AString &a_Command)
Returns the permission needed for the specified command; empty string if command not found.
bool CallHookEntityAddEffect(cEntity &a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier)
CommandMap m_Commands
bool CallHookSpawnedEntity(cWorld &a_World, cEntity &a_Entity)
bool CallHookChunkGenerating(cWorld &a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc *a_ChunkDesc)
bool CallHookPlayerRightClickingEntity(cPlayer &a_Player, cEntity &a_Entity)
bool CallHookPlayerRightClick(cPlayer &a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, Vector3i a_CursorPos)
static bool IsValidHookType(int a_HookType)
Returns true if the specified hook type is within the allowed range.
AStringVector GetFoldersToLoad(cSettingsRepositoryInterface &a_Settings)
Returns the folders that are specified in the settings ini to load plugins from.
bool CallHookChunkAvailable(cWorld &a_World, int a_ChunkX, int a_ChunkZ)
cDeadlockDetect & m_DeadlockDetect
The deadlock detect in which all plugins should track their CSs.
bool ForEachPlugin(cPluginCallback a_Callback)
Calls the specified callback for each plugin in m_Plugins.
bool CallHookPlayerFishing(cPlayer &a_Player, cItems &a_Reward, int &ExperienceAmount)
bool CallHookPlayerFoodLevelChange(cPlayer &a_Player, int a_NewFoodLevel)
bool CallHookPlayerShooting(cPlayer &a_Player)
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.
bool CallHookPlayerEating(cPlayer &a_Player)
bool CallHookHandshake(cClientHandle &a_ClientHandle, const AString &a_Username)
bool LoadPlugin(const AString &a_PluginFolder)
Loads the plugin from the specified plugin folder.
static cPluginManager * Get(void)
Returns the instance of the Plugin Manager (there is only ever one)
void RemovePluginCommands(cPlugin *a_Plugin)
Removes all command bindings that the specified plugin has made.
bool CallHookPlayerUsingItem(cPlayer &a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, Vector3i a_CursorPos)
bool CallHookPlayerTossingItem(cPlayer &a_Player)
bool CallHookServerPing(cClientHandle &a_ClientHandle, AString &a_ServerDescription, int &a_OnlinePlayersCount, int &a_MaxPlayersCount, AString &a_Favicon)
bool CallHookPlayerLeftClick(cPlayer &a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, char a_Status)
CommandMap m_ConsoleCommands
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 CallHookCollectingPickup(cPlayer &a_Player, cPickup &a_Pickup)
PluginAction
Defines the deferred actions needed for a plugin.
bool CallHookSpawnedMonster(cWorld &a_World, cMonster &a_Monster)
void ReloadPluginsNow(void)
Reloads all plugins, defaulting to settings.ini for settings location.
bool CallHookSpawningEntity(cWorld &a_World, cEntity &a_Entity)
bool CallHookLogin(cClientHandle &a_Client, UInt32 a_ProtocolVersion, const AString &a_Username)
bool CallHookDropSpense(cWorld &a_World, cDropSpenserEntity &a_DropSpenser, int a_SlotNum)
bool CallHookUpdatedSign(cWorld &a_World, Vector3i a_BlockPos, const AString &a_Line1, const AString &a_Line2, const AString &a_Line3, const AString &a_Line4, cPlayer *a_Player)
void RemoveHooks(cPlugin *a_Plugin)
Removes all hooks the specified plugin has registered.
std::list< cPlugin * > PluginList
bool CallHookPlayerCrouched(cPlayer &a_Player)
std::map< int, cPluginManager::PluginList > HookMap
size_t GetNumLoadedPlugins(void) const
Returns the number of plugins that are psLoaded.
bool CallHookChunkUnloaded(cWorld &a_World, int a_ChunkX, int a_ChunkZ)
void RefreshPluginList()
Refreshes the m_Plugins list based on the current contents of the Plugins folder.
bool CallHookPluginsLoaded(void)
bool CallHookPlayerPlacingBlock(cPlayer &a_Player, const sSetBlock &a_BlockChange)
void AddHook(cPlugin *a_Plugin, int a_HookType)
Adds the plugin to the list of plugins called for the specified hook type.
void UnloadPlugin(const AString &a_PluginFolder)
Queues the specified plugin to be unloaded in the next call to Tick().
bool CallHookPlayerSpawned(cPlayer &a_Player)
bool CallHookPlayerJoined(cPlayer &a_Player)
void RemovePluginConsoleCommands(cPlugin *a_Plugin)
Removes all console command bindings that the specified plugin has made.
void RemovePlugin(const AString &a_PluginName)
Removes the plugin of the specified name from the internal structures and deletes its object.
bool ForEachConsoleCommand(cCommandEnumCallback &a_Callback)
Calls a_Callback for each bound console command, returns true if all commands were enumerated.
void Tick(float a_Dt)
Called each tick, calls the plugins' OnTick hook, as well as processes plugin events (addition,...
bool CallHookEntityChangingWorld(cEntity &a_Entity, cWorld &a_World)
bool CallHookPlayerDestroyed(cPlayer &a_Player)
bool CallHookPlayerOpeningWindow(cPlayer &a_Player, cWindow &a_Window)
bool CallHookWorldStarted(cWorld &a_World)
void TabCompleteCommand(const AString &a_Text, AStringVector &a_Results, cPlayer *a_Player)
Appends all commands beginning with a_Text (case-insensitive) into a_Results.
void ReloadPlugins()
Schedules a reload of the plugins to happen within the next call to Tick().
void UnloadPluginsNow(void)
Unloads all plugins.
bool CallHookPlayerUsingBlock(cPlayer &a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, Vector3i a_CursorPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
bool CallHookProjectileHitEntity(cProjectileEntity &a_Projectile, cEntity &a_HitEntity)
bool m_bReloadPlugins
If set to true, all the plugins will be reloaded within the next call to Tick().
bool CallHookPlayerMoving(cPlayer &a_Player, const Vector3d &a_OldPosition, const Vector3d &a_NewPosition, bool a_PreviousIsOnGround)
bool CallHookProjectileHitBlock(cProjectileEntity &a_Projectile, Vector3i a_BlockPos, eBlockFace a_Face, const Vector3d &a_BlockHitPos)
bool CallHookPostCrafting(cPlayer &a_Player, cCraftingGrid &a_Grid, cCraftingRecipe &a_Recipe)
cCriticalSection m_CSPluginsNeedAction
Protects m_PluginsToUnload against multithreaded access.
bool CallHookEntityTeleport(cEntity &a_Entity, const Vector3d &a_OldPosition, const Vector3d &a_NewPosition)
cPluginPtrs m_Plugins
All plugins that have been found in the Plugins folder.
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)
bool CallHookPlayerUsedBlock(cPlayer &a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, Vector3i a_CursorPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
bool CallHookHopperPullingItem(cWorld &a_World, cHopperEntity &a_Hopper, int a_DstSlotNum, cBlockEntityWithItems &a_SrcEntity, int a_SrcSlotNum)
bool DoWithPlugin(const AString &a_PluginName, cPluginCallback a_Callback)
Calls the specified callback with the plugin object of the specified plugin.
bool ForEachCommand(cCommandEnumCallback &a_Callback)
Calls a_Callback for each bound command, returns true if all commands were enumerated.
bool CallHookKilled(cEntity &a_Victim, TakeDamageInfo &a_TDI, AString &a_DeathMessage)
static AString GetPluginsPath(void)
Returns the path where individual plugins' folders are expected.
bool CallHookBrewingCompleting(cWorld &a_World, cBrewingstandEntity &a_Brewingstand)
bool CallHookChunkUnloading(cWorld &a_World, int a_ChunkX, int a_ChunkZ)
CommandResult ForceExecuteCommand(cPlayer &a_Player, const AString &a_Command)
Executes the command, as if it was requested by a_Player.
bool CallHookSpawningMonster(cWorld &a_World, cMonster &a_Monster)
bool CallHookEntityChangedWorld(cEntity &a_Entity, cWorld &a_World)
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.
bool CallHookWeatherChanged(cWorld &a_World)
bool CallHookPlayerBrokenBlock(cPlayer &a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
bool IsCommandBound(const AString &a_Command)
Returns true if the command is in the command map.
bool CallHookDisconnect(cClientHandle &a_Client, const AString &a_Reason)
bool CallHookLoginForge(cClientHandle &a_Client, AStringMap &a_Mods)
bool CallHookPlayerPlacedBlock(cPlayer &a_Player, const sSetBlock &a_BlockChange)
bool IsConsoleCommandBound(const AString &a_Command)
Returns true if the console command is in the command map.
bool CallHookKilling(cEntity &a_Victim, cEntity *a_Killer, TakeDamageInfo &a_TDI)
bool CallHookUpdatingSign(cWorld &a_World, Vector3i a_BlockPos, AString &a_Line1, AString &a_Line2, AString &a_Line3, AString &a_Line4, cPlayer *a_Player)
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...
@ HOOK_ENTITY_CHANGING_WORLD
Definition: PluginManager.h:97
@ HOOK_PLAYER_RIGHT_CLICKING_ENTITY
@ HOOK_PLAYER_FOOD_LEVEL_CHANGE
bool CallHookPluginMessage(cClientHandle &a_Client, const AString &a_Channel, ContiguousByteBufferView a_Message)
bool CallHookChat(cPlayer &a_Player, AString &a_Message)
bool CallHookBlockSpread(cWorld &a_World, Vector3i a_BlockPos, eSpreadSource a_Source)
std::vector< std::pair< PluginAction, AString > > m_PluginsNeedAction
FolderNames of plugins that need an action (unload, reload, ...).
bool GenericCallHook(PluginHook a_HookName, HookFunction a_HookFunction)
Calls a_HookFunction on each plugin registered to the hook HookName.
bool CallHookHopperPushingItem(cWorld &a_World, cHopperEntity &a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems &a_DstEntity, int a_DstSlotNum)
bool CallHookWorldTick(cWorld &a_World, std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_LastTickDurationMSec)
bool CallHookPreCrafting(cPlayer &a_Player, cCraftingGrid &a_Grid, cCraftingRecipe &a_Recipe)
size_t GetNumPlugins() const
Returns the number of all plugins in m_Plugins (includes disabled, unloaded and errored plugins).
bool CallHookBrewingCompleted(cWorld &a_World, cBrewingstandEntity &a_Brewingstand)
virtual ~cPluginManager()
std::shared_ptr< cCommandHandler > cCommandHandlerPtr
CommandResult ExecuteCommand(cPlayer &a_Player, const AString &a_Command)
Executes the command, as if it was requested by a_Player.
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)
bool CallHookCraftingNoRecipe(cPlayer &a_Player, cCraftingGrid &a_Grid, cCraftingRecipe &a_Recipe)
bool CallHookTakeDamage(cEntity &a_Receiver, TakeDamageInfo &a_TDI)
void ReloadPlugin(const AString &a_PluginFolder)
Queues the specified plugin to be reloaded in the next call to Tick().
bool CallHookPlayerUsedItem(cPlayer &a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, Vector3i a_CursorPos)
bool IsPluginLoaded(const AString &a_PluginName)
Returns true if the specified plugin is loaded.
bool CallHookExecuteCommand(cPlayer *a_Player, const AStringVector &a_Split, const AString &a_EntireCommand, CommandResult &a_Result)
bool CallHookWeatherChanging(cWorld &a_World, eWeather &a_NewWeather)
bool CallHookPlayerFished(cPlayer &a_Player, const cItems &a_Reward, const int ExperienceAmount)
AString GetPluginFolderName(const AString &a_PluginName)
Returns the name of the folder (cPlugin::GetFolderName()) from which the specified plugin was loaded.
bool CallHookPlayerBreakingBlock(cPlayer &a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
std::map< AString, cCommandReg > CommandMap
ePluginStatus
Defines the status of a single plugin - whether it is loaded, disabled or errored.
Definition: PluginManager.h:60
@ psNotFound
The plugin has been loaded before, but after a folder refresh it is no longer present.
Definition: PluginManager.h:76
@ psError
The plugin is enabled in settings.ini but has failed to load.
Definition: PluginManager.h:72
@ psLoaded
The plugin has been loaded successfully.
Definition: PluginManager.h:62
@ psUnloaded
The plugin is enabled in settings.ini but has been unloaded (by a command).
Definition: PluginManager.h:68
@ psDisabled
The plugin is disabled in settings.ini.
Definition: PluginManager.h:65
bool BindConsoleCommand(const AString &a_Command, cPlugin *a_Plugin, cCommandHandlerPtr a_Handler, const AString &a_HelpString)
Binds a console command to the specified handler.
Used as a callback for enumerating bound commands.
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...
Interface that must be provided by any class that implements a command handler, either in-game or con...
virtual bool ExecuteCommand(const AStringVector &a_Split, cPlayer *a_Player, const AString &a_Command, cCommandOutputCallback *a_Output=nullptr)=0
Executes the specified in-game command.
cCommandHandlerPtr m_Handler
Interface for a callback that receives command output The Out() function is called for any output the...
Definition: CommandOutput.h:16
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
The root of the object hierarchy.
Definition: Root.h:50
Represents a UI window.
Definition: Window.h:54
Definition: World.h:53