Cuberite
A lightweight, fast and extensible game server for Minecraft
|
#include <PluginManager.h>
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 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 cPluginManager * | Get (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, cCommandReg > | CommandMap |
typedef std::map< int, cPluginManager::PluginList > | HookMap |
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... | |
cDeadlockDetect & | m_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 |
Definition at line 44 of file PluginManager.h.
typedef std::shared_ptr<cCommandHandler> cPluginManager::cCommandHandlerPtr |
Definition at line 206 of file PluginManager.h.
|
private |
Definition at line 420 of file PluginManager.h.
using cPluginManager::cPluginCallback = cFunctionRef<bool(cPlugin &)> |
The interface used for enumerating and extern-calling plugins.
Definition at line 210 of file PluginManager.h.
|
private |
Definition at line 419 of file PluginManager.h.
typedef std::list<cPlugin *> cPluginManager::PluginList |
Definition at line 212 of file PluginManager.h.
Enumerator | |
---|---|
crExecuted | |
crUnknownCommand | |
crError | |
crBlocked | |
crNoPermission |
Definition at line 48 of file PluginManager.h.
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.
|
strong |
Defines the deferred actions needed for a plugin.
Enumerator | |
---|---|
Reload | |
Unload |
Definition at line 166 of file PluginManager.h.
Definition at line 80 of file PluginManager.h.
|
private |
Definition at line 28 of file PluginManager.cpp.
|
privatevirtual |
Definition at line 38 of file PluginManager.cpp.
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.
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.
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.
bool cPluginManager::CallHookBlockSpread | ( | cWorld & | a_World, |
Vector3i | a_BlockPos, | ||
eSpreadSource | a_Source | ||
) |
Definition at line 257 of file PluginManager.cpp.
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.
bool cPluginManager::CallHookBrewingCompleted | ( | cWorld & | a_World, |
cBrewingstandEntity & | a_Brewingstand | ||
) |
Definition at line 291 of file PluginManager.cpp.
bool cPluginManager::CallHookBrewingCompleting | ( | cWorld & | a_World, |
cBrewingstandEntity & | a_Brewingstand | ||
) |
Definition at line 304 of file PluginManager.cpp.
Definition at line 317 of file PluginManager.cpp.
bool cPluginManager::CallHookChunkAvailable | ( | cWorld & | a_World, |
int | a_ChunkX, | ||
int | a_ChunkZ | ||
) |
Definition at line 377 of file PluginManager.cpp.
bool cPluginManager::CallHookChunkGenerated | ( | cWorld & | a_World, |
int | a_ChunkX, | ||
int | a_ChunkZ, | ||
cChunkDesc * | a_ChunkDesc | ||
) |
Definition at line 390 of file PluginManager.cpp.
bool cPluginManager::CallHookChunkGenerating | ( | cWorld & | a_World, |
int | a_ChunkX, | ||
int | a_ChunkZ, | ||
cChunkDesc * | a_ChunkDesc | ||
) |
Definition at line 403 of file PluginManager.cpp.
bool cPluginManager::CallHookChunkUnloaded | ( | cWorld & | a_World, |
int | a_ChunkX, | ||
int | a_ChunkZ | ||
) |
Definition at line 416 of file PluginManager.cpp.
bool cPluginManager::CallHookChunkUnloading | ( | cWorld & | a_World, |
int | a_ChunkX, | ||
int | a_ChunkZ | ||
) |
Definition at line 429 of file PluginManager.cpp.
Definition at line 442 of file PluginManager.cpp.
bool cPluginManager::CallHookCraftingNoRecipe | ( | cPlayer & | a_Player, |
cCraftingGrid & | a_Grid, | ||
cCraftingRecipe & | a_Recipe | ||
) |
Definition at line 455 of file PluginManager.cpp.
bool cPluginManager::CallHookDisconnect | ( | cClientHandle & | a_Client, |
const AString & | a_Reason | ||
) |
Definition at line 468 of file PluginManager.cpp.
bool cPluginManager::CallHookDropSpense | ( | cWorld & | a_World, |
cDropSpenserEntity & | a_DropSpenser, | ||
int | a_SlotNum | ||
) |
Definition at line 635 of file PluginManager.cpp.
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.
Definition at line 520 of file PluginManager.cpp.
Definition at line 507 of file PluginManager.cpp.
bool cPluginManager::CallHookEntityTeleport | ( | cEntity & | a_Entity, |
const Vector3d & | a_OldPosition, | ||
const Vector3d & | a_NewPosition | ||
) |
Definition at line 494 of file PluginManager.cpp.
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.
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.
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.
bool cPluginManager::CallHookHandshake | ( | cClientHandle & | a_ClientHandle, |
const AString & | a_Username | ||
) |
Definition at line 596 of file PluginManager.cpp.
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.
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.
bool cPluginManager::CallHookKilled | ( | cEntity & | a_Victim, |
TakeDamageInfo & | a_TDI, | ||
AString & | a_DeathMessage | ||
) |
Definition at line 648 of file PluginManager.cpp.
bool cPluginManager::CallHookKilling | ( | cEntity & | a_Victim, |
cEntity * | a_Killer, | ||
TakeDamageInfo & | a_TDI | ||
) |
Definition at line 661 of file PluginManager.cpp.
bool cPluginManager::CallHookLogin | ( | cClientHandle & | a_Client, |
UInt32 | a_ProtocolVersion, | ||
const AString & | a_Username | ||
) |
Definition at line 674 of file PluginManager.cpp.
bool cPluginManager::CallHookLoginForge | ( | cClientHandle & | a_Client, |
AStringMap & | a_Mods | ||
) |
Definition at line 687 of file PluginManager.cpp.
bool cPluginManager::CallHookPlayerAnimation | ( | cPlayer & | a_Player, |
int | a_Animation | ||
) |
Definition at line 700 of file PluginManager.cpp.
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.
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.
bool cPluginManager::CallHookPlayerCrouched | ( | cPlayer & | a_Player | ) |
Definition at line 882 of file PluginManager.cpp.
bool cPluginManager::CallHookPlayerDestroyed | ( | cPlayer & | a_Player | ) |
Definition at line 739 of file PluginManager.cpp.
bool cPluginManager::CallHookPlayerEating | ( | cPlayer & | a_Player | ) |
Definition at line 752 of file PluginManager.cpp.
bool cPluginManager::CallHookPlayerFished | ( | cPlayer & | a_Player, |
const cItems & | a_Reward, | ||
const int | ExperienceAmount | ||
) |
Definition at line 778 of file PluginManager.cpp.
bool cPluginManager::CallHookPlayerFishing | ( | cPlayer & | a_Player, |
cItems & | a_Reward, | ||
int & | ExperienceAmount | ||
) |
Definition at line 791 of file PluginManager.cpp.
bool cPluginManager::CallHookPlayerFoodLevelChange | ( | cPlayer & | a_Player, |
int | a_NewFoodLevel | ||
) |
Definition at line 765 of file PluginManager.cpp.
bool cPluginManager::CallHookPlayerJoined | ( | cPlayer & | a_Player | ) |
Definition at line 804 of file PluginManager.cpp.
bool cPluginManager::CallHookPlayerLeftClick | ( | cPlayer & | a_Player, |
Vector3i | a_BlockPos, | ||
eBlockFace | a_BlockFace, | ||
char | a_Status | ||
) |
Definition at line 817 of file PluginManager.cpp.
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.
Definition at line 843 of file PluginManager.cpp.
bool cPluginManager::CallHookPlayerPlacedBlock | ( | cPlayer & | a_Player, |
const sSetBlock & | a_BlockChange | ||
) |
Definition at line 856 of file PluginManager.cpp.
bool cPluginManager::CallHookPlayerPlacingBlock | ( | cPlayer & | a_Player, |
const sSetBlock & | a_BlockChange | ||
) |
Definition at line 869 of file PluginManager.cpp.
bool cPluginManager::CallHookPlayerRightClick | ( | cPlayer & | a_Player, |
Vector3i | a_BlockPos, | ||
eBlockFace | a_BlockFace, | ||
Vector3i | a_CursorPos | ||
) |
Definition at line 895 of file PluginManager.cpp.
Definition at line 908 of file PluginManager.cpp.
bool cPluginManager::CallHookPlayerShooting | ( | cPlayer & | a_Player | ) |
Definition at line 921 of file PluginManager.cpp.
bool cPluginManager::CallHookPlayerSpawned | ( | cPlayer & | a_Player | ) |
Definition at line 934 of file PluginManager.cpp.
bool cPluginManager::CallHookPlayerTossingItem | ( | cPlayer & | a_Player | ) |
Definition at line 947 of file PluginManager.cpp.
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.
bool cPluginManager::CallHookPlayerUsedItem | ( | cPlayer & | a_Player, |
Vector3i | a_BlockPos, | ||
eBlockFace | a_BlockFace, | ||
Vector3i | a_CursorPos | ||
) |
Definition at line 973 of file PluginManager.cpp.
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.
bool cPluginManager::CallHookPlayerUsingItem | ( | cPlayer & | a_Player, |
Vector3i | a_BlockPos, | ||
eBlockFace | a_BlockFace, | ||
Vector3i | a_CursorPos | ||
) |
Definition at line 999 of file PluginManager.cpp.
bool cPluginManager::CallHookPluginMessage | ( | cClientHandle & | a_Client, |
const AString & | a_Channel, | ||
ContiguousByteBufferView | a_Message | ||
) |
Definition at line 1012 of file PluginManager.cpp.
bool cPluginManager::CallHookPluginsLoaded | ( | void | ) |
Definition at line 1025 of file PluginManager.cpp.
bool cPluginManager::CallHookPostCrafting | ( | cPlayer & | a_Player, |
cCraftingGrid & | a_Grid, | ||
cCraftingRecipe & | a_Recipe | ||
) |
Definition at line 1048 of file PluginManager.cpp.
bool cPluginManager::CallHookPreCrafting | ( | cPlayer & | a_Player, |
cCraftingGrid & | a_Grid, | ||
cCraftingRecipe & | a_Recipe | ||
) |
Definition at line 1061 of file PluginManager.cpp.
bool cPluginManager::CallHookProjectileHitBlock | ( | cProjectileEntity & | a_Projectile, |
Vector3i | a_BlockPos, | ||
eBlockFace | a_Face, | ||
const Vector3d & | a_BlockHitPos | ||
) |
Definition at line 1074 of file PluginManager.cpp.
bool cPluginManager::CallHookProjectileHitEntity | ( | cProjectileEntity & | a_Projectile, |
cEntity & | a_HitEntity | ||
) |
Definition at line 1087 of file PluginManager.cpp.
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.
Definition at line 1113 of file PluginManager.cpp.
Definition at line 1126 of file PluginManager.cpp.
Definition at line 1139 of file PluginManager.cpp.
Definition at line 1152 of file PluginManager.cpp.
bool cPluginManager::CallHookTakeDamage | ( | cEntity & | a_Receiver, |
TakeDamageInfo & | a_TDI | ||
) |
Definition at line 1165 of file PluginManager.cpp.
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.
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.
bool cPluginManager::CallHookWeatherChanged | ( | cWorld & | a_World | ) |
Definition at line 1204 of file PluginManager.cpp.
Definition at line 1217 of file PluginManager.cpp.
bool cPluginManager::CallHookWorldStarted | ( | cWorld & | a_World | ) |
Definition at line 1230 of file PluginManager.cpp.
bool cPluginManager::CallHookWorldTick | ( | cWorld & | a_World, |
std::chrono::milliseconds | a_Dt, | ||
std::chrono::milliseconds | a_LastTickDurationMSec | ||
) |
Definition at line 1243 of file PluginManager.cpp.
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.
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.
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.
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.
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.
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.
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.
|
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.
|
static |
Returns the instance of the Plugin Manager (there is only ever one)
Definition at line 19 of file PluginManager.cpp.
Returns the permission needed for the specified command; empty string if command not found.
Definition at line 1481 of file PluginManager.cpp.
|
private |
Returns the folders that are specified in the settings ini to load plugins from.
Definition at line 1771 of file PluginManager.cpp.
size_t cPluginManager::GetNumLoadedPlugins | ( | void | ) | const |
Returns the number of plugins that are psLoaded.
Definition at line 1754 of file PluginManager.cpp.
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.
Returns the name of the folder (cPlugin::GetFolderName()) from which the specified plugin was loaded.
Definition at line 1710 of file PluginManager.cpp.
|
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.
|
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.
|
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.
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.
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.
bool cPluginManager::IsPluginLoaded | ( | const AString & | a_PluginName | ) |
Returns true if the specified plugin is loaded.
Definition at line 1413 of file PluginManager.cpp.
|
static |
Returns true if the specified hook type is within the allowed range.
Definition at line 1667 of file PluginManager.cpp.
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.
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.
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.
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.
|
private |
Reloads all plugins with a settings repo expected to be initialised to settings.ini.
Definition at line 115 of file PluginManager.cpp.
|
private |
Reloads all plugins, defaulting to settings.ini for settings location.
Definition at line 104 of file PluginManager.cpp.
void cPluginManager::RemoveHooks | ( | cPlugin * | a_Plugin | ) |
Removes all hooks the specified plugin has registered.
Definition at line 1380 of file PluginManager.cpp.
void cPluginManager::RemovePlugin | ( | const AString & | a_PluginName | ) |
Removes the plugin of the specified name from the internal structures and deletes its object.
void cPluginManager::RemovePluginCommands | ( | cPlugin * | a_Plugin | ) |
Removes all command bindings that the specified plugin has made.
Definition at line 1392 of file PluginManager.cpp.
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.
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.
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.
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.
|
private |
Unloads all plugins.
Definition at line 1313 of file PluginManager.cpp.
|
friend |
Definition at line 408 of file PluginManager.h.
|
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.
|
private |
Definition at line 435 of file PluginManager.h.
|
private |
Definition at line 436 of file PluginManager.h.
|
mutableprivate |
Protects m_PluginsToUnload against multithreaded access.
Definition at line 429 of file PluginManager.h.
|
private |
The deadlock detect in which all plugins should track their CSs.
Definition at line 442 of file PluginManager.h.
|
private |
Definition at line 434 of file PluginManager.h.
|
private |
All plugins that have been found in the Plugins folder.
Definition at line 432 of file PluginManager.h.
|
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.