Cuberite
A lightweight, fast and extensible game server for Minecraft
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
cPluginManager Class Reference

#include <PluginManager.h>

Collaboration diagram for cPluginManager:
Collaboration graph
[legend]

Classes

class  cCommandEnumCallback
 Used as a callback for enumerating bound commands. More...
 
class  cCommandHandler
 Interface that must be provided by any class that implements a command handler, either in-game or console command. More...
 
class  cCommandReg
 

Public Types

typedef std::shared_ptr< cCommandHandlercCommandHandlerPtr
 
enum  CommandResult {
  crExecuted , crUnknownCommand , crError , crBlocked ,
  crNoPermission
}
 
using cPluginCallback = cFunctionRef< bool(cPlugin &)>
 The interface used for enumerating and extern-calling plugins. More...
 
enum  ePluginStatus {
  psLoaded , psDisabled , psUnloaded , psError ,
  psNotFound
}
 Defines the status of a single plugin - whether it is loaded, disabled or errored. More...
 
enum class  PluginAction { Reload , Unload }
 Defines the deferred actions needed for a plugin. More...
 
enum  PluginHook {
  HOOK_BLOCK_SPREAD , HOOK_BLOCK_TO_PICKUPS , HOOK_BREWING_COMPLETING , HOOK_BREWING_COMPLETED ,
  HOOK_CHAT , HOOK_CHUNK_AVAILABLE , HOOK_CHUNK_GENERATED , HOOK_CHUNK_GENERATING ,
  HOOK_CHUNK_UNLOADED , HOOK_CHUNK_UNLOADING , HOOK_COLLECTING_PICKUP , HOOK_CRAFTING_NO_RECIPE ,
  HOOK_DISCONNECT , HOOK_PLAYER_ANIMATION , HOOK_ENTITY_ADD_EFFECT , HOOK_ENTITY_CHANGING_WORLD ,
  HOOK_ENTITY_CHANGED_WORLD , HOOK_EXECUTE_COMMAND , HOOK_EXPLODED , HOOK_EXPLODING ,
  HOOK_HANDSHAKE , HOOK_HOPPER_PULLING_ITEM , HOOK_HOPPER_PUSHING_ITEM , HOOK_DROPSPENSE ,
  HOOK_KILLED , HOOK_KILLING , HOOK_LOGIN , HOOK_LOGIN_FORGE ,
  HOOK_PLAYER_BREAKING_BLOCK , HOOK_PLAYER_BROKEN_BLOCK , HOOK_PLAYER_DESTROYED , HOOK_PLAYER_EATING ,
  HOOK_PLAYER_FISHED , HOOK_PLAYER_FISHING , HOOK_PLAYER_FOOD_LEVEL_CHANGE , HOOK_PLAYER_JOINED ,
  HOOK_PLAYER_LEFT_CLICK , HOOK_PLAYER_MOVING , HOOK_PLAYER_OPENING_WINDOW , HOOK_PLAYER_PLACED_BLOCK ,
  HOOK_PLAYER_PLACING_BLOCK , HOOK_PLAYER_CROUCHED , HOOK_PLAYER_RIGHT_CLICK , HOOK_PLAYER_RIGHT_CLICKING_ENTITY ,
  HOOK_PLAYER_SHOOTING , HOOK_PLAYER_SPAWNED , HOOK_ENTITY_TELEPORT , HOOK_PLAYER_TOSSING_ITEM ,
  HOOK_PLAYER_USED_BLOCK , HOOK_PLAYER_USED_ITEM , HOOK_PLAYER_USING_BLOCK , HOOK_PLAYER_USING_ITEM ,
  HOOK_PLUGIN_MESSAGE , HOOK_PLUGINS_LOADED , HOOK_POST_CRAFTING , HOOK_PRE_CRAFTING ,
  HOOK_PROJECTILE_HIT_BLOCK , HOOK_PROJECTILE_HIT_ENTITY , HOOK_SERVER_PING , HOOK_SPAWNED_ENTITY ,
  HOOK_SPAWNED_MONSTER , HOOK_SPAWNING_ENTITY , HOOK_SPAWNING_MONSTER , HOOK_TAKE_DAMAGE ,
  HOOK_TICK , HOOK_UPDATED_SIGN , HOOK_UPDATING_SIGN , HOOK_WEATHER_CHANGED ,
  HOOK_WEATHER_CHANGING , HOOK_WORLD_STARTED , HOOK_WORLD_TICK , HOOK_NUM_HOOKS ,
  HOOK_MAX = HOOK_NUM_HOOKS - 1
}
 
typedef std::list< cPlugin * > PluginList
 

Public Member Functions

void AddHook (cPlugin *a_Plugin, int a_HookType)
 Adds the plugin to the list of plugins called for the specified hook type. More...
 
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. More...
 
bool BindConsoleCommand (const AString &a_Command, cPlugin *a_Plugin, cCommandHandlerPtr a_Handler, const AString &a_HelpString)
 Binds a console command to the specified handler. More...
 
bool CallHookBlockSpread (cWorld &a_World, Vector3i a_BlockPos, eSpreadSource a_Source)
 
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 CallHookBrewingCompleted (cWorld &a_World, cBrewingstandEntity &a_Brewingstand)
 
bool CallHookBrewingCompleting (cWorld &a_World, cBrewingstandEntity &a_Brewingstand)
 
bool CallHookChat (cPlayer &a_Player, AString &a_Message)
 
bool CallHookChunkAvailable (cWorld &a_World, int a_ChunkX, int a_ChunkZ)
 
bool CallHookChunkGenerated (cWorld &a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc *a_ChunkDesc)
 
bool CallHookChunkGenerating (cWorld &a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc *a_ChunkDesc)
 
bool CallHookChunkUnloaded (cWorld &a_World, int a_ChunkX, int a_ChunkZ)
 
bool CallHookChunkUnloading (cWorld &a_World, int a_ChunkX, int a_ChunkZ)
 
bool CallHookCollectingPickup (cPlayer &a_Player, cPickup &a_Pickup)
 
bool CallHookCraftingNoRecipe (cPlayer &a_Player, cCraftingGrid &a_Grid, cCraftingRecipe &a_Recipe)
 
bool CallHookDisconnect (cClientHandle &a_Client, const AString &a_Reason)
 
bool CallHookDropSpense (cWorld &a_World, cDropSpenserEntity &a_DropSpenser, int a_SlotNum)
 
bool CallHookEntityAddEffect (cEntity &a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier)
 
bool CallHookEntityChangedWorld (cEntity &a_Entity, cWorld &a_World)
 
bool CallHookEntityChangingWorld (cEntity &a_Entity, cWorld &a_World)
 
bool CallHookEntityTeleport (cEntity &a_Entity, const Vector3d &a_OldPosition, const Vector3d &a_NewPosition)
 
bool CallHookExecuteCommand (cPlayer *a_Player, const AStringVector &a_Split, const AString &a_EntireCommand, CommandResult &a_Result)
 
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 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 CallHookHandshake (cClientHandle &a_ClientHandle, const AString &a_Username)
 
bool CallHookHopperPullingItem (cWorld &a_World, cHopperEntity &a_Hopper, int a_DstSlotNum, cBlockEntityWithItems &a_SrcEntity, int a_SrcSlotNum)
 
bool CallHookHopperPushingItem (cWorld &a_World, cHopperEntity &a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems &a_DstEntity, int a_DstSlotNum)
 
bool CallHookKilled (cEntity &a_Victim, TakeDamageInfo &a_TDI, AString &a_DeathMessage)
 
bool CallHookKilling (cEntity &a_Victim, cEntity *a_Killer, TakeDamageInfo &a_TDI)
 
bool CallHookLogin (cClientHandle &a_Client, UInt32 a_ProtocolVersion, const AString &a_Username)
 
bool CallHookLoginForge (cClientHandle &a_Client, AStringMap &a_Mods)
 
bool CallHookPlayerAnimation (cPlayer &a_Player, int a_Animation)
 
bool CallHookPlayerBreakingBlock (cPlayer &a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
 
bool CallHookPlayerBrokenBlock (cPlayer &a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
 
bool CallHookPlayerCrouched (cPlayer &a_Player)
 
bool CallHookPlayerDestroyed (cPlayer &a_Player)
 
bool CallHookPlayerEating (cPlayer &a_Player)
 
bool CallHookPlayerFished (cPlayer &a_Player, const cItems &a_Reward, const int ExperienceAmount)
 
bool CallHookPlayerFishing (cPlayer &a_Player, cItems &a_Reward, int &ExperienceAmount)
 
bool CallHookPlayerFoodLevelChange (cPlayer &a_Player, int a_NewFoodLevel)
 
bool CallHookPlayerJoined (cPlayer &a_Player)
 
bool CallHookPlayerLeftClick (cPlayer &a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, char a_Status)
 
bool CallHookPlayerMoving (cPlayer &a_Player, const Vector3d &a_OldPosition, const Vector3d &a_NewPosition, bool a_PreviousIsOnGround)
 
bool CallHookPlayerOpeningWindow (cPlayer &a_Player, cWindow &a_Window)
 
bool CallHookPlayerPlacedBlock (cPlayer &a_Player, const sSetBlock &a_BlockChange)
 
bool CallHookPlayerPlacingBlock (cPlayer &a_Player, const sSetBlock &a_BlockChange)
 
bool CallHookPlayerRightClick (cPlayer &a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, Vector3i a_CursorPos)
 
bool CallHookPlayerRightClickingEntity (cPlayer &a_Player, cEntity &a_Entity)
 
bool CallHookPlayerShooting (cPlayer &a_Player)
 
bool CallHookPlayerSpawned (cPlayer &a_Player)
 
bool CallHookPlayerTossingItem (cPlayer &a_Player)
 
bool CallHookPlayerUsedBlock (cPlayer &a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, Vector3i a_CursorPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
 
bool CallHookPlayerUsedItem (cPlayer &a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, Vector3i a_CursorPos)
 
bool CallHookPlayerUsingBlock (cPlayer &a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, Vector3i a_CursorPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
 
bool CallHookPlayerUsingItem (cPlayer &a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, Vector3i a_CursorPos)
 
bool CallHookPluginMessage (cClientHandle &a_Client, const AString &a_Channel, ContiguousByteBufferView a_Message)
 
bool CallHookPluginsLoaded (void)
 
bool CallHookPostCrafting (cPlayer &a_Player, cCraftingGrid &a_Grid, cCraftingRecipe &a_Recipe)
 
bool CallHookPreCrafting (cPlayer &a_Player, cCraftingGrid &a_Grid, cCraftingRecipe &a_Recipe)
 
bool CallHookProjectileHitBlock (cProjectileEntity &a_Projectile, Vector3i a_BlockPos, eBlockFace a_Face, const Vector3d &a_BlockHitPos)
 
bool CallHookProjectileHitEntity (cProjectileEntity &a_Projectile, cEntity &a_HitEntity)
 
bool CallHookServerPing (cClientHandle &a_ClientHandle, AString &a_ServerDescription, int &a_OnlinePlayersCount, int &a_MaxPlayersCount, AString &a_Favicon)
 
bool CallHookSpawnedEntity (cWorld &a_World, cEntity &a_Entity)
 
bool CallHookSpawnedMonster (cWorld &a_World, cMonster &a_Monster)
 
bool CallHookSpawningEntity (cWorld &a_World, cEntity &a_Entity)
 
bool CallHookSpawningMonster (cWorld &a_World, cMonster &a_Monster)
 
bool CallHookTakeDamage (cEntity &a_Receiver, TakeDamageInfo &a_TDI)
 
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)
 
bool CallHookUpdatingSign (cWorld &a_World, Vector3i a_BlockPos, AString &a_Line1, AString &a_Line2, AString &a_Line3, AString &a_Line4, cPlayer *a_Player)
 
bool CallHookWeatherChanged (cWorld &a_World)
 
bool CallHookWeatherChanging (cWorld &a_World, eWeather &a_NewWeather)
 
bool CallHookWorldStarted (cWorld &a_World)
 
bool CallHookWorldTick (cWorld &a_World, std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_LastTickDurationMSec)
 
bool DoWithPlugin (const AString &a_PluginName, cPluginCallback a_Callback)
 Calls the specified callback with the plugin object of the specified plugin. More...
 
CommandResult ExecuteCommand (cPlayer &a_Player, const AString &a_Command)
 Executes the command, as if it was requested by a_Player. More...
 
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. More...
 
CommandResult ForceExecuteCommand (cPlayer &a_Player, const AString &a_Command)
 Executes the command, as if it was requested by a_Player. More...
 
bool ForEachCommand (cCommandEnumCallback &a_Callback)
 Calls a_Callback for each bound command, returns true if all commands were enumerated. More...
 
bool ForEachConsoleCommand (cCommandEnumCallback &a_Callback)
 Calls a_Callback for each bound console command, returns true if all commands were enumerated. More...
 
bool ForEachPlugin (cPluginCallback a_Callback)
 Calls the specified callback for each plugin in m_Plugins. More...
 
AString GetCommandPermission (const AString &a_Command)
 Returns the permission needed for the specified command; empty string if command not found. More...
 
size_t GetNumLoadedPlugins (void) const
 Returns the number of plugins that are psLoaded. More...
 
size_t GetNumPlugins () const
 Returns the number of all plugins in m_Plugins (includes disabled, unloaded and errored plugins). More...
 
AString GetPluginFolderName (const AString &a_PluginName)
 Returns the name of the folder (cPlugin::GetFolderName()) from which the specified plugin was loaded. More...
 
bool IsCommandBound (const AString &a_Command)
 Returns true if the command is in the command map. More...
 
bool IsConsoleCommandBound (const AString &a_Command)
 Returns true if the console command is in the command map. More...
 
bool IsPluginLoaded (const AString &a_PluginName)
 Returns true if the specified plugin is loaded. More...
 
bool LoadPlugin (const AString &a_PluginFolder)
 Loads the plugin from the specified plugin folder. More...
 
void RefreshPluginList ()
 Refreshes the m_Plugins list based on the current contents of the Plugins folder. More...
 
void ReloadPlugin (const AString &a_PluginFolder)
 Queues the specified plugin to be reloaded in the next call to Tick(). More...
 
void ReloadPlugins ()
 Schedules a reload of the plugins to happen within the next call to Tick(). More...
 
void RemoveHooks (cPlugin *a_Plugin)
 Removes all hooks the specified plugin has registered. More...
 
void RemovePlugin (const AString &a_PluginName)
 Removes the plugin of the specified name from the internal structures and deletes its object. More...
 
void RemovePluginCommands (cPlugin *a_Plugin)
 Removes all command bindings that the specified plugin has made. More...
 
void RemovePluginConsoleCommands (cPlugin *a_Plugin)
 Removes all console command bindings that the specified plugin has made. More...
 
void TabCompleteCommand (const AString &a_Text, AStringVector &a_Results, cPlayer *a_Player)
 Appends all commands beginning with a_Text (case-insensitive) into a_Results. More...
 
void Tick (float a_Dt)
 Called each tick, calls the plugins' OnTick hook, as well as processes plugin events (addition, removal) More...
 
void UnloadPlugin (const AString &a_PluginFolder)
 Queues the specified plugin to be unloaded in the next call to Tick(). More...
 

Static Public Member Functions

static cPluginManagerGet (void)
 Returns the instance of the Plugin Manager (there is only ever one) More...
 
static AString GetPluginsPath (void)
 Returns the path where individual plugins' folders are expected. More...
 
static bool IsValidHookType (int a_HookType)
 Returns true if the specified hook type is within the allowed range. More...
 

Private Types

typedef std::map< AString, cCommandRegCommandMap
 
typedef std::map< int, cPluginManager::PluginListHookMap
 

Private Member Functions

 cPluginManager (cDeadlockDetect &a_DeadlockDetect)
 
template<typename HookFunction >
bool GenericCallHook (PluginHook a_HookName, HookFunction a_HookFunction)
 Calls a_HookFunction on each plugin registered to the hook HookName. More...
 
AStringVector GetFoldersToLoad (cSettingsRepositoryInterface &a_Settings)
 Returns the folders that are specified in the settings ini to load plugins from. More...
 
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 plugin is called. More...
 
void InsertDefaultPlugins (cSettingsRepositoryInterface &a_Settings)
 Handles writing default plugins if 'Plugins' key not found using a settings repo expected to be intialised to settings.ini. More...
 
void ReloadPluginsNow (cSettingsRepositoryInterface &a_Settings)
 Reloads all plugins with a settings repo expected to be initialised to settings.ini. More...
 
void ReloadPluginsNow (void)
 Reloads all plugins, defaulting to settings.ini for settings location. More...
 
void UnloadPluginsNow (void)
 Unloads all plugins. More...
 
virtual ~cPluginManager ()
 

Private Attributes

bool m_bReloadPlugins
 If set to true, all the plugins will be reloaded within the next call to Tick(). More...
 
CommandMap m_Commands
 
CommandMap m_ConsoleCommands
 
cCriticalSection m_CSPluginsNeedAction
 Protects m_PluginsToUnload against multithreaded access. More...
 
cDeadlockDetectm_DeadlockDetect
 The deadlock detect in which all plugins should track their CSs. More...
 
HookMap m_Hooks
 
cPluginPtrs m_Plugins
 All plugins that have been found in the Plugins folder. More...
 
std::vector< std::pair< PluginAction, AString > > m_PluginsNeedAction
 FolderNames of plugins that need an action (unload, reload, ...). More...
 

Friends

class cRoot
 

Detailed Description

Definition at line 44 of file PluginManager.h.

Member Typedef Documentation

◆ cCommandHandlerPtr

Definition at line 206 of file PluginManager.h.

◆ CommandMap

typedef std::map<AString, cCommandReg> cPluginManager::CommandMap
private

Definition at line 420 of file PluginManager.h.

◆ cPluginCallback

The interface used for enumerating and extern-calling plugins.

Definition at line 210 of file PluginManager.h.

◆ HookMap

typedef std::map<int, cPluginManager::PluginList> cPluginManager::HookMap
private

Definition at line 419 of file PluginManager.h.

◆ PluginList

typedef std::list<cPlugin *> cPluginManager::PluginList

Definition at line 212 of file PluginManager.h.

Member Enumeration Documentation

◆ CommandResult

Enumerator
crExecuted 
crUnknownCommand 
crError 
crBlocked 
crNoPermission 

Definition at line 48 of file PluginManager.h.

◆ ePluginStatus

Defines the status of a single plugin - whether it is loaded, disabled or errored.

Enumerator
psLoaded 

The plugin has been loaded successfully.

psDisabled 

The plugin is disabled in settings.ini.

psUnloaded 

The plugin is enabled in settings.ini but has been unloaded (by a command).

psError 

The plugin is enabled in settings.ini but has failed to load.

m_LoadError is the description of the error.

psNotFound 

The plugin has been loaded before, but after a folder refresh it is no longer present.

The plugin will be unloaded in the next call to ReloadPlugins().

Definition at line 59 of file PluginManager.h.

◆ PluginAction

Defines the deferred actions needed for a plugin.

Enumerator
Reload 
Unload 

Definition at line 166 of file PluginManager.h.

◆ PluginHook

Enumerator
HOOK_BLOCK_SPREAD 
HOOK_BLOCK_TO_PICKUPS 
HOOK_BREWING_COMPLETING 
HOOK_BREWING_COMPLETED 
HOOK_CHAT 
HOOK_CHUNK_AVAILABLE 
HOOK_CHUNK_GENERATED 
HOOK_CHUNK_GENERATING 
HOOK_CHUNK_UNLOADED 
HOOK_CHUNK_UNLOADING 
HOOK_COLLECTING_PICKUP 
HOOK_CRAFTING_NO_RECIPE 
HOOK_DISCONNECT 
HOOK_PLAYER_ANIMATION 
HOOK_ENTITY_ADD_EFFECT 
HOOK_ENTITY_CHANGING_WORLD 
HOOK_ENTITY_CHANGED_WORLD 
HOOK_EXECUTE_COMMAND 
HOOK_EXPLODED 
HOOK_EXPLODING 
HOOK_HANDSHAKE 
HOOK_HOPPER_PULLING_ITEM 
HOOK_HOPPER_PUSHING_ITEM 
HOOK_DROPSPENSE 
HOOK_KILLED 
HOOK_KILLING 
HOOK_LOGIN 
HOOK_LOGIN_FORGE 
HOOK_PLAYER_BREAKING_BLOCK 
HOOK_PLAYER_BROKEN_BLOCK 
HOOK_PLAYER_DESTROYED 
HOOK_PLAYER_EATING 
HOOK_PLAYER_FISHED 
HOOK_PLAYER_FISHING 
HOOK_PLAYER_FOOD_LEVEL_CHANGE 
HOOK_PLAYER_JOINED 
HOOK_PLAYER_LEFT_CLICK 
HOOK_PLAYER_MOVING 
HOOK_PLAYER_OPENING_WINDOW 
HOOK_PLAYER_PLACED_BLOCK 
HOOK_PLAYER_PLACING_BLOCK 
HOOK_PLAYER_CROUCHED 
HOOK_PLAYER_RIGHT_CLICK 
HOOK_PLAYER_RIGHT_CLICKING_ENTITY 
HOOK_PLAYER_SHOOTING 
HOOK_PLAYER_SPAWNED 
HOOK_ENTITY_TELEPORT 
HOOK_PLAYER_TOSSING_ITEM 
HOOK_PLAYER_USED_BLOCK 
HOOK_PLAYER_USED_ITEM 
HOOK_PLAYER_USING_BLOCK 
HOOK_PLAYER_USING_ITEM 
HOOK_PLUGIN_MESSAGE 
HOOK_PLUGINS_LOADED 
HOOK_POST_CRAFTING 
HOOK_PRE_CRAFTING 
HOOK_PROJECTILE_HIT_BLOCK 
HOOK_PROJECTILE_HIT_ENTITY 
HOOK_SERVER_PING 
HOOK_SPAWNED_ENTITY 
HOOK_SPAWNED_MONSTER 
HOOK_SPAWNING_ENTITY 
HOOK_SPAWNING_MONSTER 
HOOK_TAKE_DAMAGE 
HOOK_TICK 
HOOK_UPDATED_SIGN 
HOOK_UPDATING_SIGN 
HOOK_WEATHER_CHANGED 
HOOK_WEATHER_CHANGING 
HOOK_WORLD_STARTED 
HOOK_WORLD_TICK 
HOOK_NUM_HOOKS 
HOOK_MAX 

Definition at line 80 of file PluginManager.h.

Constructor & Destructor Documentation

◆ cPluginManager()

cPluginManager::cPluginManager ( cDeadlockDetect a_DeadlockDetect)
private

Definition at line 28 of file PluginManager.cpp.

◆ ~cPluginManager()

cPluginManager::~cPluginManager ( )
privatevirtual

Definition at line 38 of file PluginManager.cpp.

Member Function Documentation

◆ AddHook()

void cPluginManager::AddHook ( cPlugin a_Plugin,
int  a_HookType 
)

Adds the plugin to the list of plugins called for the specified hook type.

If a plugin adds multiple handlers for a single hook, it is added only once (ignore-duplicates).

Definition at line 1727 of file PluginManager.cpp.

◆ BindCommand()

bool cPluginManager::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.

Returns true if successful, false if command already bound. Exported in ManualBindings.cpp.

Definition at line 1429 of file PluginManager.cpp.

◆ BindConsoleCommand()

bool cPluginManager::BindConsoleCommand ( const AString a_Command,
cPlugin a_Plugin,
cCommandHandlerPtr  a_Handler,
const AString a_HelpString 
)

Binds a console command to the specified handler.

Returns true if successful, false if command already bound. Exported in ManualBindings.cpp.

Definition at line 1530 of file PluginManager.cpp.

◆ CallHookBlockSpread()

bool cPluginManager::CallHookBlockSpread ( cWorld a_World,
Vector3i  a_BlockPos,
eSpreadSource  a_Source 
)

Definition at line 257 of file PluginManager.cpp.

◆ CallHookBlockToPickups()

bool cPluginManager::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 
)

Definition at line 270 of file PluginManager.cpp.

◆ CallHookBrewingCompleted()

bool cPluginManager::CallHookBrewingCompleted ( cWorld a_World,
cBrewingstandEntity a_Brewingstand 
)

Definition at line 291 of file PluginManager.cpp.

◆ CallHookBrewingCompleting()

bool cPluginManager::CallHookBrewingCompleting ( cWorld a_World,
cBrewingstandEntity a_Brewingstand 
)

Definition at line 304 of file PluginManager.cpp.

◆ CallHookChat()

bool cPluginManager::CallHookChat ( cPlayer a_Player,
AString a_Message 
)

Definition at line 317 of file PluginManager.cpp.

◆ CallHookChunkAvailable()

bool cPluginManager::CallHookChunkAvailable ( cWorld a_World,
int  a_ChunkX,
int  a_ChunkZ 
)

Definition at line 377 of file PluginManager.cpp.

◆ CallHookChunkGenerated()

bool cPluginManager::CallHookChunkGenerated ( cWorld a_World,
int  a_ChunkX,
int  a_ChunkZ,
cChunkDesc a_ChunkDesc 
)

Definition at line 390 of file PluginManager.cpp.

◆ CallHookChunkGenerating()

bool cPluginManager::CallHookChunkGenerating ( cWorld a_World,
int  a_ChunkX,
int  a_ChunkZ,
cChunkDesc a_ChunkDesc 
)

Definition at line 403 of file PluginManager.cpp.

◆ CallHookChunkUnloaded()

bool cPluginManager::CallHookChunkUnloaded ( cWorld a_World,
int  a_ChunkX,
int  a_ChunkZ 
)

Definition at line 416 of file PluginManager.cpp.

◆ CallHookChunkUnloading()

bool cPluginManager::CallHookChunkUnloading ( cWorld a_World,
int  a_ChunkX,
int  a_ChunkZ 
)

Definition at line 429 of file PluginManager.cpp.

◆ CallHookCollectingPickup()

bool cPluginManager::CallHookCollectingPickup ( cPlayer a_Player,
cPickup a_Pickup 
)

Definition at line 442 of file PluginManager.cpp.

◆ CallHookCraftingNoRecipe()

bool cPluginManager::CallHookCraftingNoRecipe ( cPlayer a_Player,
cCraftingGrid a_Grid,
cCraftingRecipe a_Recipe 
)

Definition at line 455 of file PluginManager.cpp.

◆ CallHookDisconnect()

bool cPluginManager::CallHookDisconnect ( cClientHandle a_Client,
const AString a_Reason 
)

Definition at line 468 of file PluginManager.cpp.

◆ CallHookDropSpense()

bool cPluginManager::CallHookDropSpense ( cWorld a_World,
cDropSpenserEntity a_DropSpenser,
int  a_SlotNum 
)

Definition at line 635 of file PluginManager.cpp.

◆ CallHookEntityAddEffect()

bool cPluginManager::CallHookEntityAddEffect ( cEntity a_Entity,
int  a_EffectType,
int  a_EffectDurationTicks,
int  a_EffectIntensity,
double  a_DistanceModifier 
)

Definition at line 481 of file PluginManager.cpp.

◆ CallHookEntityChangedWorld()

bool cPluginManager::CallHookEntityChangedWorld ( cEntity a_Entity,
cWorld a_World 
)

Definition at line 520 of file PluginManager.cpp.

◆ CallHookEntityChangingWorld()

bool cPluginManager::CallHookEntityChangingWorld ( cEntity a_Entity,
cWorld a_World 
)

Definition at line 507 of file PluginManager.cpp.

◆ CallHookEntityTeleport()

bool cPluginManager::CallHookEntityTeleport ( cEntity a_Entity,
const Vector3d a_OldPosition,
const Vector3d a_NewPosition 
)

Definition at line 494 of file PluginManager.cpp.

◆ CallHookExecuteCommand()

bool cPluginManager::CallHookExecuteCommand ( cPlayer a_Player,
const AStringVector a_Split,
const AString a_EntireCommand,
CommandResult a_Result 
)

Definition at line 533 of file PluginManager.cpp.

◆ CallHookExploded()

bool cPluginManager::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 
)

Definition at line 570 of file PluginManager.cpp.

◆ CallHookExploding()

bool cPluginManager::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 
)

Definition at line 583 of file PluginManager.cpp.

◆ CallHookHandshake()

bool cPluginManager::CallHookHandshake ( cClientHandle a_ClientHandle,
const AString a_Username 
)

Definition at line 596 of file PluginManager.cpp.

◆ CallHookHopperPullingItem()

bool cPluginManager::CallHookHopperPullingItem ( cWorld a_World,
cHopperEntity a_Hopper,
int  a_DstSlotNum,
cBlockEntityWithItems a_SrcEntity,
int  a_SrcSlotNum 
)

Definition at line 609 of file PluginManager.cpp.

◆ CallHookHopperPushingItem()

bool cPluginManager::CallHookHopperPushingItem ( cWorld a_World,
cHopperEntity a_Hopper,
int  a_SrcSlotNum,
cBlockEntityWithItems a_DstEntity,
int  a_DstSlotNum 
)

Definition at line 622 of file PluginManager.cpp.

◆ CallHookKilled()

bool cPluginManager::CallHookKilled ( cEntity a_Victim,
TakeDamageInfo a_TDI,
AString a_DeathMessage 
)

Definition at line 648 of file PluginManager.cpp.

◆ CallHookKilling()

bool cPluginManager::CallHookKilling ( cEntity a_Victim,
cEntity a_Killer,
TakeDamageInfo a_TDI 
)

Definition at line 661 of file PluginManager.cpp.

◆ CallHookLogin()

bool cPluginManager::CallHookLogin ( cClientHandle a_Client,
UInt32  a_ProtocolVersion,
const AString a_Username 
)

Definition at line 674 of file PluginManager.cpp.

◆ CallHookLoginForge()

bool cPluginManager::CallHookLoginForge ( cClientHandle a_Client,
AStringMap a_Mods 
)

Definition at line 687 of file PluginManager.cpp.

◆ CallHookPlayerAnimation()

bool cPluginManager::CallHookPlayerAnimation ( cPlayer a_Player,
int  a_Animation 
)

Definition at line 700 of file PluginManager.cpp.

◆ CallHookPlayerBreakingBlock()

bool cPluginManager::CallHookPlayerBreakingBlock ( cPlayer a_Player,
Vector3i  a_BlockPos,
eBlockFace  a_BlockFace,
BLOCKTYPE  a_BlockType,
NIBBLETYPE  a_BlockMeta 
)

Definition at line 713 of file PluginManager.cpp.

◆ CallHookPlayerBrokenBlock()

bool cPluginManager::CallHookPlayerBrokenBlock ( cPlayer a_Player,
Vector3i  a_BlockPos,
eBlockFace  a_BlockFace,
BLOCKTYPE  a_BlockType,
NIBBLETYPE  a_BlockMeta 
)

Definition at line 726 of file PluginManager.cpp.

◆ CallHookPlayerCrouched()

bool cPluginManager::CallHookPlayerCrouched ( cPlayer a_Player)

Definition at line 882 of file PluginManager.cpp.

◆ CallHookPlayerDestroyed()

bool cPluginManager::CallHookPlayerDestroyed ( cPlayer a_Player)

Definition at line 739 of file PluginManager.cpp.

◆ CallHookPlayerEating()

bool cPluginManager::CallHookPlayerEating ( cPlayer a_Player)

Definition at line 752 of file PluginManager.cpp.

◆ CallHookPlayerFished()

bool cPluginManager::CallHookPlayerFished ( cPlayer a_Player,
const cItems a_Reward,
const int  ExperienceAmount 
)

Definition at line 778 of file PluginManager.cpp.

◆ CallHookPlayerFishing()

bool cPluginManager::CallHookPlayerFishing ( cPlayer a_Player,
cItems a_Reward,
int &  ExperienceAmount 
)

Definition at line 791 of file PluginManager.cpp.

◆ CallHookPlayerFoodLevelChange()

bool cPluginManager::CallHookPlayerFoodLevelChange ( cPlayer a_Player,
int  a_NewFoodLevel 
)

Definition at line 765 of file PluginManager.cpp.

◆ CallHookPlayerJoined()

bool cPluginManager::CallHookPlayerJoined ( cPlayer a_Player)

Definition at line 804 of file PluginManager.cpp.

◆ CallHookPlayerLeftClick()

bool cPluginManager::CallHookPlayerLeftClick ( cPlayer a_Player,
Vector3i  a_BlockPos,
eBlockFace  a_BlockFace,
char  a_Status 
)

Definition at line 817 of file PluginManager.cpp.

◆ CallHookPlayerMoving()

bool cPluginManager::CallHookPlayerMoving ( cPlayer a_Player,
const Vector3d a_OldPosition,
const Vector3d a_NewPosition,
bool  a_PreviousIsOnGround 
)

Definition at line 830 of file PluginManager.cpp.

◆ CallHookPlayerOpeningWindow()

bool cPluginManager::CallHookPlayerOpeningWindow ( cPlayer a_Player,
cWindow a_Window 
)

Definition at line 843 of file PluginManager.cpp.

◆ CallHookPlayerPlacedBlock()

bool cPluginManager::CallHookPlayerPlacedBlock ( cPlayer a_Player,
const sSetBlock a_BlockChange 
)

Definition at line 856 of file PluginManager.cpp.

◆ CallHookPlayerPlacingBlock()

bool cPluginManager::CallHookPlayerPlacingBlock ( cPlayer a_Player,
const sSetBlock a_BlockChange 
)

Definition at line 869 of file PluginManager.cpp.

◆ CallHookPlayerRightClick()

bool cPluginManager::CallHookPlayerRightClick ( cPlayer a_Player,
Vector3i  a_BlockPos,
eBlockFace  a_BlockFace,
Vector3i  a_CursorPos 
)

Definition at line 895 of file PluginManager.cpp.

◆ CallHookPlayerRightClickingEntity()

bool cPluginManager::CallHookPlayerRightClickingEntity ( cPlayer a_Player,
cEntity a_Entity 
)

Definition at line 908 of file PluginManager.cpp.

◆ CallHookPlayerShooting()

bool cPluginManager::CallHookPlayerShooting ( cPlayer a_Player)

Definition at line 921 of file PluginManager.cpp.

◆ CallHookPlayerSpawned()

bool cPluginManager::CallHookPlayerSpawned ( cPlayer a_Player)

Definition at line 934 of file PluginManager.cpp.

◆ CallHookPlayerTossingItem()

bool cPluginManager::CallHookPlayerTossingItem ( cPlayer a_Player)

Definition at line 947 of file PluginManager.cpp.

◆ CallHookPlayerUsedBlock()

bool cPluginManager::CallHookPlayerUsedBlock ( cPlayer a_Player,
Vector3i  a_BlockPos,
eBlockFace  a_BlockFace,
Vector3i  a_CursorPos,
BLOCKTYPE  a_BlockType,
NIBBLETYPE  a_BlockMeta 
)

Definition at line 960 of file PluginManager.cpp.

◆ CallHookPlayerUsedItem()

bool cPluginManager::CallHookPlayerUsedItem ( cPlayer a_Player,
Vector3i  a_BlockPos,
eBlockFace  a_BlockFace,
Vector3i  a_CursorPos 
)

Definition at line 973 of file PluginManager.cpp.

◆ CallHookPlayerUsingBlock()

bool cPluginManager::CallHookPlayerUsingBlock ( cPlayer a_Player,
Vector3i  a_BlockPos,
eBlockFace  a_BlockFace,
Vector3i  a_CursorPos,
BLOCKTYPE  a_BlockType,
NIBBLETYPE  a_BlockMeta 
)

Definition at line 986 of file PluginManager.cpp.

◆ CallHookPlayerUsingItem()

bool cPluginManager::CallHookPlayerUsingItem ( cPlayer a_Player,
Vector3i  a_BlockPos,
eBlockFace  a_BlockFace,
Vector3i  a_CursorPos 
)

Definition at line 999 of file PluginManager.cpp.

◆ CallHookPluginMessage()

bool cPluginManager::CallHookPluginMessage ( cClientHandle a_Client,
const AString a_Channel,
ContiguousByteBufferView  a_Message 
)

Definition at line 1012 of file PluginManager.cpp.

◆ CallHookPluginsLoaded()

bool cPluginManager::CallHookPluginsLoaded ( void  )

Definition at line 1025 of file PluginManager.cpp.

◆ CallHookPostCrafting()

bool cPluginManager::CallHookPostCrafting ( cPlayer a_Player,
cCraftingGrid a_Grid,
cCraftingRecipe a_Recipe 
)

Definition at line 1048 of file PluginManager.cpp.

◆ CallHookPreCrafting()

bool cPluginManager::CallHookPreCrafting ( cPlayer a_Player,
cCraftingGrid a_Grid,
cCraftingRecipe a_Recipe 
)

Definition at line 1061 of file PluginManager.cpp.

◆ CallHookProjectileHitBlock()

bool cPluginManager::CallHookProjectileHitBlock ( cProjectileEntity a_Projectile,
Vector3i  a_BlockPos,
eBlockFace  a_Face,
const Vector3d a_BlockHitPos 
)

Definition at line 1074 of file PluginManager.cpp.

◆ CallHookProjectileHitEntity()

bool cPluginManager::CallHookProjectileHitEntity ( cProjectileEntity a_Projectile,
cEntity a_HitEntity 
)

Definition at line 1087 of file PluginManager.cpp.

◆ CallHookServerPing()

bool cPluginManager::CallHookServerPing ( cClientHandle a_ClientHandle,
AString a_ServerDescription,
int &  a_OnlinePlayersCount,
int &  a_MaxPlayersCount,
AString a_Favicon 
)

Definition at line 1100 of file PluginManager.cpp.

◆ CallHookSpawnedEntity()

bool cPluginManager::CallHookSpawnedEntity ( cWorld a_World,
cEntity a_Entity 
)

Definition at line 1113 of file PluginManager.cpp.

◆ CallHookSpawnedMonster()

bool cPluginManager::CallHookSpawnedMonster ( cWorld a_World,
cMonster a_Monster 
)

Definition at line 1126 of file PluginManager.cpp.

◆ CallHookSpawningEntity()

bool cPluginManager::CallHookSpawningEntity ( cWorld a_World,
cEntity a_Entity 
)

Definition at line 1139 of file PluginManager.cpp.

◆ CallHookSpawningMonster()

bool cPluginManager::CallHookSpawningMonster ( cWorld a_World,
cMonster a_Monster 
)

Definition at line 1152 of file PluginManager.cpp.

◆ CallHookTakeDamage()

bool cPluginManager::CallHookTakeDamage ( cEntity a_Receiver,
TakeDamageInfo a_TDI 
)

Definition at line 1165 of file PluginManager.cpp.

◆ CallHookUpdatedSign()

bool cPluginManager::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 
)

Definition at line 1191 of file PluginManager.cpp.

◆ CallHookUpdatingSign()

bool cPluginManager::CallHookUpdatingSign ( cWorld a_World,
Vector3i  a_BlockPos,
AString a_Line1,
AString a_Line2,
AString a_Line3,
AString a_Line4,
cPlayer a_Player 
)

Definition at line 1178 of file PluginManager.cpp.

◆ CallHookWeatherChanged()

bool cPluginManager::CallHookWeatherChanged ( cWorld a_World)

Definition at line 1204 of file PluginManager.cpp.

◆ CallHookWeatherChanging()

bool cPluginManager::CallHookWeatherChanging ( cWorld a_World,
eWeather a_NewWeather 
)

Definition at line 1217 of file PluginManager.cpp.

◆ CallHookWorldStarted()

bool cPluginManager::CallHookWorldStarted ( cWorld a_World)

Definition at line 1230 of file PluginManager.cpp.

◆ CallHookWorldTick()

bool cPluginManager::CallHookWorldTick ( cWorld a_World,
std::chrono::milliseconds  a_Dt,
std::chrono::milliseconds  a_LastTickDurationMSec 
)

Definition at line 1243 of file PluginManager.cpp.

◆ DoWithPlugin()

bool cPluginManager::DoWithPlugin ( const AString a_PluginName,
cPluginCallback  a_Callback 
)

Calls the specified callback with the plugin object of the specified plugin.

Returns false if plugin not found, otherwise returns the value that the callback has returned.

Definition at line 1676 of file PluginManager.cpp.

◆ ExecuteCommand()

cPluginManager::CommandResult cPluginManager::ExecuteCommand ( cPlayer a_Player,
const AString a_Command 
)

Executes the command, as if it was requested by a_Player.

Checks permissions first. Returns crExecuted if executed.

Definition at line 1491 of file PluginManager.cpp.

◆ ExecuteConsoleCommand()

bool cPluginManager::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.

Returns true if executed. Output is sent to the a_Output callback Exported in ManualBindings.cpp with a different signature.

Definition at line 1588 of file PluginManager.cpp.

◆ ForceExecuteCommand()

cPluginManager::CommandResult cPluginManager::ForceExecuteCommand ( cPlayer a_Player,
const AString a_Command 
)

Executes the command, as if it was requested by a_Player.

Permisssions are not checked. Returns crExecuted if executed.

Definition at line 1500 of file PluginManager.cpp.

◆ ForEachCommand()

bool cPluginManager::ForEachCommand ( cCommandEnumCallback a_Callback)

Calls a_Callback for each bound command, returns true if all commands were enumerated.

Definition at line 1456 of file PluginManager.cpp.

◆ ForEachConsoleCommand()

bool cPluginManager::ForEachConsoleCommand ( cCommandEnumCallback a_Callback)

Calls a_Callback for each bound console command, returns true if all commands were enumerated.

Definition at line 1563 of file PluginManager.cpp.

◆ ForEachPlugin()

bool cPluginManager::ForEachPlugin ( cPluginCallback  a_Callback)

Calls the specified callback for each plugin in m_Plugins.

Returns true if all plugins have been reported, false if the callback has aborted the enumeration by returning true.

Definition at line 1693 of file PluginManager.cpp.

◆ GenericCallHook()

template<typename HookFunction >
bool cPluginManager::GenericCallHook ( PluginHook  a_HookName,
HookFunction  a_HookFunction 
)
private

Calls a_HookFunction on each plugin registered to the hook HookName.

Returns false if the action is to continue or true if the plugin wants to abort. Accessible only from within PluginManager.cpp

Definition at line 242 of file PluginManager.cpp.

◆ Get()

cPluginManager * cPluginManager::Get ( void  )
static

Returns the instance of the Plugin Manager (there is only ever one)

Definition at line 19 of file PluginManager.cpp.

◆ GetCommandPermission()

AString cPluginManager::GetCommandPermission ( const AString a_Command)

Returns the permission needed for the specified command; empty string if command not found.

Definition at line 1481 of file PluginManager.cpp.

◆ GetFoldersToLoad()

AStringVector cPluginManager::GetFoldersToLoad ( cSettingsRepositoryInterface a_Settings)
private

Returns the folders that are specified in the settings ini to load plugins from.

Definition at line 1771 of file PluginManager.cpp.

◆ GetNumLoadedPlugins()

size_t cPluginManager::GetNumLoadedPlugins ( void  ) const

Returns the number of plugins that are psLoaded.

Definition at line 1754 of file PluginManager.cpp.

◆ GetNumPlugins()

size_t cPluginManager::GetNumPlugins ( void  ) const

Returns the number of all plugins in m_Plugins (includes disabled, unloaded and errored plugins).

Definition at line 1745 of file PluginManager.cpp.

◆ GetPluginFolderName()

AString cPluginManager::GetPluginFolderName ( const AString a_PluginName)

Returns the name of the folder (cPlugin::GetFolderName()) from which the specified plugin was loaded.

Definition at line 1710 of file PluginManager.cpp.

◆ GetPluginsPath()

static AString cPluginManager::GetPluginsPath ( void  )
inlinestatic

Returns the path where individual plugins' folders are expected.

The path doesn't end in a slash.

Definition at line 405 of file PluginManager.h.

◆ HandleCommand()

cPluginManager::CommandResult cPluginManager::HandleCommand ( cPlayer a_Player,
const AString a_Command,
bool  a_ShouldCheckPermissions 
)
private

Tries to match a_Command to the internal table of commands, if a match is found, the corresponding plugin is called.

Returns crExecuted if the command is executed.

Definition at line 1256 of file PluginManager.cpp.

◆ InsertDefaultPlugins()

void cPluginManager::InsertDefaultPlugins ( cSettingsRepositoryInterface a_Settings)
private

Handles writing default plugins if 'Plugins' key not found using a settings repo expected to be intialised to settings.ini.

Definition at line 154 of file PluginManager.cpp.

◆ IsCommandBound()

bool cPluginManager::IsCommandBound ( const AString a_Command)

Returns true if the command is in the command map.

Definition at line 1472 of file PluginManager.cpp.

◆ IsConsoleCommandBound()

bool cPluginManager::IsConsoleCommandBound ( const AString a_Command)

Returns true if the console command is in the command map.

Definition at line 1579 of file PluginManager.cpp.

◆ IsPluginLoaded()

bool cPluginManager::IsPluginLoaded ( const AString a_PluginName)

Returns true if the specified plugin is loaded.

Definition at line 1413 of file PluginManager.cpp.

◆ IsValidHookType()

bool cPluginManager::IsValidHookType ( int  a_HookType)
static

Returns true if the specified hook type is within the allowed range.

Definition at line 1667 of file PluginManager.cpp.

◆ LoadPlugin()

bool cPluginManager::LoadPlugin ( const AString a_PluginFolder)

Loads the plugin from the specified plugin folder.

Returns true if the plugin was loaded successfully or was already loaded before, false otherwise.

Definition at line 1357 of file PluginManager.cpp.

◆ RefreshPluginList()

void cPluginManager::RefreshPluginList ( void  )

Refreshes the m_Plugins list based on the current contents of the Plugins folder.

If an active plugin's folder is not found anymore, the plugin is set as psNotFound, but not yet unloaded.

Definition at line 56 of file PluginManager.cpp.

◆ ReloadPlugin()

void cPluginManager::ReloadPlugin ( const AString a_PluginFolder)

Queues the specified plugin to be reloaded in the next call to Tick().

Note that this function returns before the plugin is unloaded, to avoid deadlocks.

Definition at line 1347 of file PluginManager.cpp.

◆ ReloadPlugins()

void cPluginManager::ReloadPlugins ( void  )

Schedules a reload of the plugins to happen within the next call to Tick().

Definition at line 47 of file PluginManager.cpp.

◆ ReloadPluginsNow() [1/2]

void cPluginManager::ReloadPluginsNow ( cSettingsRepositoryInterface a_Settings)
private

Reloads all plugins with a settings repo expected to be initialised to settings.ini.

Definition at line 115 of file PluginManager.cpp.

◆ ReloadPluginsNow() [2/2]

void cPluginManager::ReloadPluginsNow ( void  )
private

Reloads all plugins, defaulting to settings.ini for settings location.

Definition at line 104 of file PluginManager.cpp.

◆ RemoveHooks()

void cPluginManager::RemoveHooks ( cPlugin a_Plugin)

Removes all hooks the specified plugin has registered.

Definition at line 1380 of file PluginManager.cpp.

◆ RemovePlugin()

void cPluginManager::RemovePlugin ( const AString a_PluginName)

Removes the plugin of the specified name from the internal structures and deletes its object.

◆ RemovePluginCommands()

void cPluginManager::RemovePluginCommands ( cPlugin a_Plugin)

Removes all command bindings that the specified plugin has made.

Definition at line 1392 of file PluginManager.cpp.

◆ RemovePluginConsoleCommands()

void cPluginManager::RemovePluginConsoleCommands ( cPlugin a_Plugin)

Removes all console command bindings that the specified plugin has made.

Definition at line 1509 of file PluginManager.cpp.

◆ TabCompleteCommand()

void cPluginManager::TabCompleteCommand ( const AString a_Text,
AStringVector a_Results,
cPlayer a_Player 
)

Appends all commands beginning with a_Text (case-insensitive) into a_Results.

If a_Player is not nullptr, only commands for which the player has permissions are added.

Definition at line 1625 of file PluginManager.cpp.

◆ Tick()

void cPluginManager::Tick ( float  a_Dt)

Called each tick, calls the plugins' OnTick hook, as well as processes plugin events (addition, removal)

Definition at line 166 of file PluginManager.cpp.

◆ UnloadPlugin()

void cPluginManager::UnloadPlugin ( const AString a_PluginFolder)

Queues the specified plugin to be unloaded in the next call to Tick().

Note that this function returns before the plugin is unloaded, to avoid deadlocks.

Definition at line 1337 of file PluginManager.cpp.

◆ UnloadPluginsNow()

void cPluginManager::UnloadPluginsNow ( void  )
private

Unloads all plugins.

Definition at line 1313 of file PluginManager.cpp.

Friends And Related Function Documentation

◆ cRoot

friend class cRoot
friend

Definition at line 408 of file PluginManager.h.

Member Data Documentation

◆ m_bReloadPlugins

bool cPluginManager::m_bReloadPlugins
private

If set to true, all the plugins will be reloaded within the next call to Tick().

Definition at line 439 of file PluginManager.h.

◆ m_Commands

CommandMap cPluginManager::m_Commands
private

Definition at line 435 of file PluginManager.h.

◆ m_ConsoleCommands

CommandMap cPluginManager::m_ConsoleCommands
private

Definition at line 436 of file PluginManager.h.

◆ m_CSPluginsNeedAction

cCriticalSection cPluginManager::m_CSPluginsNeedAction
mutableprivate

Protects m_PluginsToUnload against multithreaded access.

Definition at line 429 of file PluginManager.h.

◆ m_DeadlockDetect

cDeadlockDetect& cPluginManager::m_DeadlockDetect
private

The deadlock detect in which all plugins should track their CSs.

Definition at line 442 of file PluginManager.h.

◆ m_Hooks

HookMap cPluginManager::m_Hooks
private

Definition at line 434 of file PluginManager.h.

◆ m_Plugins

cPluginPtrs cPluginManager::m_Plugins
private

All plugins that have been found in the Plugins folder.

Definition at line 432 of file PluginManager.h.

◆ m_PluginsNeedAction

std::vector<std::pair<PluginAction, AString> > cPluginManager::m_PluginsNeedAction
private

FolderNames of plugins that need an action (unload, reload, ...).

The plugins will be acted upon within the next call to Tick(), to avoid multithreading issues. Protected against multithreaded access by m_CSPluginsNeedAction.

Definition at line 426 of file PluginManager.h.


The documentation for this class was generated from the following files: