summaryrefslogtreecommitdiffstats
path: root/src/Bindings/PluginManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Bindings/PluginManager.cpp')
-rw-r--r--src/Bindings/PluginManager.cpp865
1 files changed, 546 insertions, 319 deletions
diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp
index 4f48a07ea..67fec79cc 100644
--- a/src/Bindings/PluginManager.cpp
+++ b/src/Bindings/PluginManager.cpp
@@ -26,8 +26,7 @@ cPluginManager * cPluginManager::Get(void)
cPluginManager::cPluginManager(cDeadlockDetect & a_DeadlockDetect) :
- m_bReloadPlugins(false),
- m_DeadlockDetect(a_DeadlockDetect)
+ m_bReloadPlugins(false), m_DeadlockDetect(a_DeadlockDetect)
{
}
@@ -59,7 +58,7 @@ void cPluginManager::RefreshPluginList(void)
AString PluginsPath = GetPluginsPath() + "/";
AStringVector Contents = cFile::GetFolderContents(PluginsPath);
AStringVector Folders;
- for (auto & item: Contents)
+ for (auto & item : Contents)
{
if (!cFile::IsFolder(PluginsPath + item))
{
@@ -70,7 +69,7 @@ void cPluginManager::RefreshPluginList(void)
} // for item - Contents[]
// Set all plugins with invalid folders as psNotFound:
- for (auto & plugin: m_Plugins)
+ for (auto & plugin : m_Plugins)
{
if (std::find(Folders.cbegin(), Folders.cend(), plugin->GetFolderName()) == Folders.end())
{
@@ -79,10 +78,10 @@ void cPluginManager::RefreshPluginList(void)
} // for plugin - m_Plugins[]
// Add all newly discovered plugins:
- for (auto & folder: Folders)
+ for (auto & folder : Folders)
{
bool hasFound = false;
- for (auto & plugin: m_Plugins)
+ for (auto & plugin : m_Plugins)
{
if (plugin->GetFolderName() == folder)
{
@@ -125,7 +124,7 @@ void cPluginManager::ReloadPluginsNow(cSettingsRepositoryInterface & a_Settings)
// Load the plugins:
AStringVector ToLoad = GetFoldersToLoad(a_Settings);
- for (auto & pluginFolder: ToLoad)
+ for (auto & pluginFolder : ToLoad)
{
LoadPlugin(pluginFolder);
} // for pluginFolder - ToLoad[]
@@ -179,7 +178,7 @@ void cPluginManager::Tick(float a_Dt)
bool WasLoaded = false;
bool WasFound = false;
- for (auto & Plugin: m_Plugins)
+ for (auto & Plugin : m_Plugins)
{
if (Plugin->GetFolderName() == Folder)
{
@@ -188,14 +187,14 @@ void cPluginManager::Tick(float a_Dt)
{
switch (Action)
{
- case PluginAction::Reload :
+ case PluginAction::Reload:
{
// Reload plugins by unloading, then loading:
Plugin->Unload();
Plugin->Load();
break;
}
- case PluginAction::Unload :
+ case PluginAction::Unload:
{
// Unload plugins that have been scheduled for unloading:
Plugin->Unload();
@@ -256,10 +255,10 @@ bool cPluginManager::GenericCallHook(PluginHook a_HookName, HookFunction a_HookF
bool cPluginManager::CallHookBlockSpread(cWorld & a_World, Vector3i a_BlockPos, eSpreadSource a_Source)
{
- return GenericCallHook(HOOK_BLOCK_SPREAD, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnBlockSpread(a_World, a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, a_Source);
- }
+ return GenericCallHook(
+ HOOK_BLOCK_SPREAD,
+ [&](cPlugin * a_Plugin)
+ { return a_Plugin->OnBlockSpread(a_World, a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, a_Source); }
);
}
@@ -270,16 +269,28 @@ bool cPluginManager::CallHookBlockSpread(cWorld & a_World, Vector3i a_BlockPos,
bool cPluginManager::CallHookBlockToPickups(
cWorld & a_World,
Vector3i a_BlockPos,
- BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta,
const cBlockEntity * a_BlockEntity,
const cEntity * a_Digger,
const cItem * a_Tool,
cItems & a_Pickups
)
{
- return GenericCallHook(HOOK_BLOCK_TO_PICKUPS, [&](cPlugin * a_Plugin)
+ return GenericCallHook(
+ HOOK_BLOCK_TO_PICKUPS,
+ [&](cPlugin * a_Plugin)
{
- return a_Plugin->OnBlockToPickups(a_World, a_BlockPos, a_BlockType, a_BlockMeta, a_BlockEntity, a_Digger, a_Tool, a_Pickups);
+ return a_Plugin->OnBlockToPickups(
+ a_World,
+ a_BlockPos,
+ a_BlockType,
+ a_BlockMeta,
+ a_BlockEntity,
+ a_Digger,
+ a_Tool,
+ a_Pickups
+ );
}
);
}
@@ -290,10 +301,9 @@ bool cPluginManager::CallHookBlockToPickups(
bool cPluginManager::CallHookBrewingCompleted(cWorld & a_World, cBrewingstandEntity & a_Brewingstand)
{
- return GenericCallHook(HOOK_BREWING_COMPLETED, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnBrewingCompleted(a_World, a_Brewingstand);
- }
+ return GenericCallHook(
+ HOOK_BREWING_COMPLETED,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnBrewingCompleted(a_World, a_Brewingstand); }
);
}
@@ -303,10 +313,9 @@ bool cPluginManager::CallHookBrewingCompleted(cWorld & a_World, cBrewingstandEnt
bool cPluginManager::CallHookBrewingCompleting(cWorld & a_World, cBrewingstandEntity & a_Brewingstand)
{
- return GenericCallHook(HOOK_BREWING_COMPLETING, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnBrewingCompleting(a_World, a_Brewingstand);
- }
+ return GenericCallHook(
+ HOOK_BREWING_COMPLETING,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnBrewingCompleting(a_World, a_Brewingstand); }
);
}
@@ -335,14 +344,18 @@ bool cPluginManager::CallHookChat(cPlayer & a_Player, AString & a_Message)
case crError:
{
// An error in the plugin has prevented the command from executing. Report the error to the player:
- a_Player.SendMessageFailure(fmt::format(FMT_STRING("Something went wrong while executing command \"{}\""), a_Message));
+ a_Player.SendMessageFailure(
+ fmt::format(FMT_STRING("Something went wrong while executing command \"{}\""), a_Message)
+ );
return true;
}
case crNoPermission:
{
// The player is not allowed to execute this command
- a_Player.SendMessageFailure(fmt::format(FMT_STRING("Forbidden command; insufficient privileges: \"{}\""), a_Message));
+ a_Player.SendMessageFailure(
+ fmt::format(FMT_STRING("Forbidden command; insufficient privileges: \"{}\""), a_Message)
+ );
return true;
}
@@ -357,17 +370,14 @@ bool cPluginManager::CallHookChat(cPlayer & a_Player, AString & a_Message)
if (!a_Message.empty() && (a_Message[0] == '/'))
{
AStringVector Split(StringSplit(a_Message, " "));
- ASSERT(!Split.empty()); // This should not happen - we know there's at least one char in the message so the split needs to be at least one item long
+ ASSERT(!Split.empty()); // This should not happen - we know there's at least one char in the message so the
+ // split needs to be at least one item long
a_Player.SendMessageInfo(fmt::format(FMT_STRING("Unknown command: \"{}\""), a_Message));
LOGINFO("Player %s issued an unknown command: \"%s\"", a_Player.GetName(), a_Message);
return true; // Cancel sending
}
- return GenericCallHook(HOOK_CHAT, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnChat(a_Player, a_Message);
- }
- );
+ return GenericCallHook(HOOK_CHAT, [&](cPlugin * a_Plugin) { return a_Plugin->OnChat(a_Player, a_Message); });
}
@@ -376,10 +386,9 @@ bool cPluginManager::CallHookChat(cPlayer & a_Player, AString & a_Message)
bool cPluginManager::CallHookChunkAvailable(cWorld & a_World, int a_ChunkX, int a_ChunkZ)
{
- return GenericCallHook(HOOK_CHUNK_AVAILABLE, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnChunkAvailable(a_World, a_ChunkX, a_ChunkZ);
- }
+ return GenericCallHook(
+ HOOK_CHUNK_AVAILABLE,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnChunkAvailable(a_World, a_ChunkX, a_ChunkZ); }
);
}
@@ -389,10 +398,9 @@ bool cPluginManager::CallHookChunkAvailable(cWorld & a_World, int a_ChunkX, int
bool cPluginManager::CallHookChunkGenerated(cWorld & a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc)
{
- return GenericCallHook(HOOK_CHUNK_GENERATED, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnChunkGenerated(a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc);
- }
+ return GenericCallHook(
+ HOOK_CHUNK_GENERATED,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnChunkGenerated(a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc); }
);
}
@@ -402,10 +410,9 @@ bool cPluginManager::CallHookChunkGenerated(cWorld & a_World, int a_ChunkX, int
bool cPluginManager::CallHookChunkGenerating(cWorld & a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc)
{
- return GenericCallHook(HOOK_CHUNK_GENERATING, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnChunkGenerating(a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc);
- }
+ return GenericCallHook(
+ HOOK_CHUNK_GENERATING,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnChunkGenerating(a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc); }
);
}
@@ -415,10 +422,9 @@ bool cPluginManager::CallHookChunkGenerating(cWorld & a_World, int a_ChunkX, int
bool cPluginManager::CallHookChunkUnloaded(cWorld & a_World, int a_ChunkX, int a_ChunkZ)
{
- return GenericCallHook(HOOK_CHUNK_UNLOADED, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnChunkUnloaded(a_World, a_ChunkX, a_ChunkZ);
- }
+ return GenericCallHook(
+ HOOK_CHUNK_UNLOADED,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnChunkUnloaded(a_World, a_ChunkX, a_ChunkZ); }
);
}
@@ -428,10 +434,9 @@ bool cPluginManager::CallHookChunkUnloaded(cWorld & a_World, int a_ChunkX, int a
bool cPluginManager::CallHookChunkUnloading(cWorld & a_World, int a_ChunkX, int a_ChunkZ)
{
- return GenericCallHook(HOOK_CHUNK_UNLOADING, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnChunkUnloading(a_World, a_ChunkX, a_ChunkZ);
- }
+ return GenericCallHook(
+ HOOK_CHUNK_UNLOADING,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnChunkUnloading(a_World, a_ChunkX, a_ChunkZ); }
);
}
@@ -441,10 +446,9 @@ bool cPluginManager::CallHookChunkUnloading(cWorld & a_World, int a_ChunkX, int
bool cPluginManager::CallHookCollectingPickup(cPlayer & a_Player, cPickup & a_Pickup)
{
- return GenericCallHook(HOOK_COLLECTING_PICKUP, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnCollectingPickup(a_Player, a_Pickup);
- }
+ return GenericCallHook(
+ HOOK_COLLECTING_PICKUP,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnCollectingPickup(a_Player, a_Pickup); }
);
}
@@ -454,10 +458,9 @@ bool cPluginManager::CallHookCollectingPickup(cPlayer & a_Player, cPickup & a_Pi
bool cPluginManager::CallHookCraftingNoRecipe(cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe & a_Recipe)
{
- return GenericCallHook(HOOK_CRAFTING_NO_RECIPE, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnCraftingNoRecipe(a_Player, a_Grid, a_Recipe);
- }
+ return GenericCallHook(
+ HOOK_CRAFTING_NO_RECIPE,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnCraftingNoRecipe(a_Player, a_Grid, a_Recipe); }
);
}
@@ -467,10 +470,9 @@ bool cPluginManager::CallHookCraftingNoRecipe(cPlayer & a_Player, cCraftingGrid
bool cPluginManager::CallHookDisconnect(cClientHandle & a_Client, const AString & a_Reason)
{
- return GenericCallHook(HOOK_DISCONNECT, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnDisconnect(a_Client, a_Reason);
- }
+ return GenericCallHook(
+ HOOK_DISCONNECT,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnDisconnect(a_Client, a_Reason); }
);
}
@@ -478,11 +480,25 @@ bool cPluginManager::CallHookDisconnect(cClientHandle & a_Client, const AString
-bool cPluginManager::CallHookEntityAddEffect(cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier)
+bool cPluginManager::CallHookEntityAddEffect(
+ cEntity & a_Entity,
+ int a_EffectType,
+ int a_EffectDurationTicks,
+ int a_EffectIntensity,
+ double a_DistanceModifier
+)
{
- return GenericCallHook(HOOK_ENTITY_ADD_EFFECT, [&](cPlugin * a_Plugin)
+ return GenericCallHook(
+ HOOK_ENTITY_ADD_EFFECT,
+ [&](cPlugin * a_Plugin)
{
- return a_Plugin->OnEntityAddEffect(a_Entity, a_EffectType, a_EffectDurationTicks, a_EffectIntensity, a_DistanceModifier);
+ return a_Plugin->OnEntityAddEffect(
+ a_Entity,
+ a_EffectType,
+ a_EffectDurationTicks,
+ a_EffectIntensity,
+ a_DistanceModifier
+ );
}
);
}
@@ -491,12 +507,15 @@ bool cPluginManager::CallHookEntityAddEffect(cEntity & a_Entity, int a_EffectTyp
-bool cPluginManager::CallHookEntityTeleport(cEntity & a_Entity, const Vector3d & a_OldPosition, const Vector3d & a_NewPosition)
+bool cPluginManager::CallHookEntityTeleport(
+ cEntity & a_Entity,
+ const Vector3d & a_OldPosition,
+ const Vector3d & a_NewPosition
+)
{
- return GenericCallHook(HOOK_ENTITY_TELEPORT, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnEntityTeleport(a_Entity, a_OldPosition, a_NewPosition);
- }
+ return GenericCallHook(
+ HOOK_ENTITY_TELEPORT,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnEntityTeleport(a_Entity, a_OldPosition, a_NewPosition); }
);
}
@@ -506,10 +525,9 @@ bool cPluginManager::CallHookEntityTeleport(cEntity & a_Entity, const Vector3d &
bool cPluginManager::CallHookEntityChangingWorld(cEntity & a_Entity, cWorld & a_World)
{
- return GenericCallHook(HOOK_ENTITY_CHANGING_WORLD, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnEntityChangingWorld(a_Entity, a_World);
- }
+ return GenericCallHook(
+ HOOK_ENTITY_CHANGING_WORLD,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnEntityChangingWorld(a_Entity, a_World); }
);
}
@@ -519,10 +537,9 @@ bool cPluginManager::CallHookEntityChangingWorld(cEntity & a_Entity, cWorld & a_
bool cPluginManager::CallHookEntityChangedWorld(cEntity & a_Entity, cWorld & a_World)
{
- return GenericCallHook(HOOK_ENTITY_CHANGED_WORLD, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnEntityChangedWorld(a_Entity, a_World);
- }
+ return GenericCallHook(
+ HOOK_ENTITY_CHANGED_WORLD,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnEntityChangedWorld(a_Entity, a_World); }
);
}
@@ -530,7 +547,12 @@ bool cPluginManager::CallHookEntityChangedWorld(cEntity & a_Entity, cWorld & a_W
-bool cPluginManager::CallHookExecuteCommand(cPlayer * a_Player, const AStringVector & a_Split, const AString & a_EntireCommand, CommandResult & a_Result)
+bool cPluginManager::CallHookExecuteCommand(
+ cPlayer * a_Player,
+ const AStringVector & a_Split,
+ const AString & a_EntireCommand,
+ CommandResult & a_Result
+)
{
// Output the command being executed to log (for troubleshooting deadlocks-in-commands):
if (a_Player != nullptr)
@@ -552,14 +574,12 @@ bool cPluginManager::CallHookExecuteCommand(cPlayer * a_Player, const AStringVec
a_Player->GetName().c_str(),
a_EntireCommand.c_str(),
worldName.c_str(),
- worldAge
- );
+ worldAge);
}
- return GenericCallHook(HOOK_EXECUTE_COMMAND, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnExecuteCommand(a_Player, a_Split, a_EntireCommand, a_Result);
- }
+ return GenericCallHook(
+ HOOK_EXECUTE_COMMAND,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnExecuteCommand(a_Player, a_Split, a_EntireCommand, a_Result); }
);
}
@@ -567,11 +587,23 @@ bool cPluginManager::CallHookExecuteCommand(cPlayer * a_Player, const AStringVec
-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)
+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
+)
{
- return GenericCallHook(HOOK_EXPLODED, [&](cPlugin * a_Plugin)
+ return GenericCallHook(
+ HOOK_EXPLODED,
+ [&](cPlugin * a_Plugin)
{
- return a_Plugin->OnExploded(a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData);
+ return a_Plugin
+ ->OnExploded(a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData);
}
);
}
@@ -580,11 +612,23 @@ bool cPluginManager::CallHookExploded(cWorld & a_World, double a_ExplosionSize,
-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)
+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
+)
{
- return GenericCallHook(HOOK_EXPLODING, [&](cPlugin * a_Plugin)
+ return GenericCallHook(
+ HOOK_EXPLODING,
+ [&](cPlugin * a_Plugin)
{
- return a_Plugin->OnExploding(a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData);
+ return a_Plugin
+ ->OnExploding(a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData);
}
);
}
@@ -595,10 +639,9 @@ bool cPluginManager::CallHookExploding(cWorld & a_World, double & a_ExplosionSiz
bool cPluginManager::CallHookHandshake(cClientHandle & a_ClientHandle, const AString & a_Username)
{
- return GenericCallHook(HOOK_HANDSHAKE, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnHandshake(a_ClientHandle, a_Username);
- }
+ return GenericCallHook(
+ HOOK_HANDSHAKE,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnHandshake(a_ClientHandle, a_Username); }
);
}
@@ -606,12 +649,18 @@ bool cPluginManager::CallHookHandshake(cClientHandle & a_ClientHandle, const ASt
-bool cPluginManager::CallHookHopperPullingItem(cWorld & a_World, cHopperEntity & a_Hopper, int a_DstSlotNum, cBlockEntityWithItems & a_SrcEntity, int a_SrcSlotNum)
+bool cPluginManager::CallHookHopperPullingItem(
+ cWorld & a_World,
+ cHopperEntity & a_Hopper,
+ int a_DstSlotNum,
+ cBlockEntityWithItems & a_SrcEntity,
+ int a_SrcSlotNum
+)
{
- return GenericCallHook(HOOK_HOPPER_PULLING_ITEM, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnHopperPullingItem(a_World, a_Hopper, a_DstSlotNum, a_SrcEntity, a_SrcSlotNum);
- }
+ return GenericCallHook(
+ HOOK_HOPPER_PULLING_ITEM,
+ [&](cPlugin * a_Plugin)
+ { return a_Plugin->OnHopperPullingItem(a_World, a_Hopper, a_DstSlotNum, a_SrcEntity, a_SrcSlotNum); }
);
}
@@ -619,12 +668,18 @@ bool cPluginManager::CallHookHopperPullingItem(cWorld & a_World, cHopperEntity &
-bool cPluginManager::CallHookHopperPushingItem(cWorld & a_World, cHopperEntity & a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems & a_DstEntity, int a_DstSlotNum)
+bool cPluginManager::CallHookHopperPushingItem(
+ cWorld & a_World,
+ cHopperEntity & a_Hopper,
+ int a_SrcSlotNum,
+ cBlockEntityWithItems & a_DstEntity,
+ int a_DstSlotNum
+)
{
- return GenericCallHook(HOOK_HOPPER_PUSHING_ITEM, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnHopperPushingItem(a_World, a_Hopper, a_SrcSlotNum, a_DstEntity, a_DstSlotNum);
- }
+ return GenericCallHook(
+ HOOK_HOPPER_PUSHING_ITEM,
+ [&](cPlugin * a_Plugin)
+ { return a_Plugin->OnHopperPushingItem(a_World, a_Hopper, a_SrcSlotNum, a_DstEntity, a_DstSlotNum); }
);
}
@@ -634,10 +689,9 @@ bool cPluginManager::CallHookHopperPushingItem(cWorld & a_World, cHopperEntity &
bool cPluginManager::CallHookDropSpense(cWorld & a_World, cDropSpenserEntity & a_DropSpenser, int a_SlotNum)
{
- return GenericCallHook(HOOK_DROPSPENSE, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnDropSpense(a_World, a_DropSpenser, a_SlotNum);
- }
+ return GenericCallHook(
+ HOOK_DROPSPENSE,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnDropSpense(a_World, a_DropSpenser, a_SlotNum); }
);
}
@@ -647,10 +701,9 @@ bool cPluginManager::CallHookDropSpense(cWorld & a_World, cDropSpenserEntity & a
bool cPluginManager::CallHookKilled(cEntity & a_Victim, TakeDamageInfo & a_TDI, AString & a_DeathMessage)
{
- return GenericCallHook(HOOK_KILLED, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnKilled(a_Victim, a_TDI, a_DeathMessage);
- }
+ return GenericCallHook(
+ HOOK_KILLED,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnKilled(a_Victim, a_TDI, a_DeathMessage); }
);
}
@@ -660,10 +713,9 @@ bool cPluginManager::CallHookKilled(cEntity & a_Victim, TakeDamageInfo & a_TDI,
bool cPluginManager::CallHookKilling(cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI)
{
- return GenericCallHook(HOOK_KILLING, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnKilling(a_Victim, a_Killer, a_TDI);
- }
+ return GenericCallHook(
+ HOOK_KILLING,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnKilling(a_Victim, a_Killer, a_TDI); }
);
}
@@ -673,10 +725,9 @@ bool cPluginManager::CallHookKilling(cEntity & a_Victim, cEntity * a_Killer, Tak
bool cPluginManager::CallHookLogin(cClientHandle & a_Client, UInt32 a_ProtocolVersion, const AString & a_Username)
{
- return GenericCallHook(HOOK_LOGIN, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnLogin(a_Client, a_ProtocolVersion, a_Username);
- }
+ return GenericCallHook(
+ HOOK_LOGIN,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnLogin(a_Client, a_ProtocolVersion, a_Username); }
);
}
@@ -686,10 +737,9 @@ bool cPluginManager::CallHookLogin(cClientHandle & a_Client, UInt32 a_ProtocolVe
bool cPluginManager::CallHookLoginForge(cClientHandle & a_Client, AStringMap & a_Mods)
{
- return GenericCallHook(HOOK_LOGIN_FORGE, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnLoginForge(a_Client, a_Mods);
- }
+ return GenericCallHook(
+ HOOK_LOGIN_FORGE,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnLoginForge(a_Client, a_Mods); }
);
}
@@ -699,10 +749,9 @@ bool cPluginManager::CallHookLoginForge(cClientHandle & a_Client, AStringMap & a
bool cPluginManager::CallHookPlayerAnimation(cPlayer & a_Player, int a_Animation)
{
- return GenericCallHook(HOOK_PLAYER_ANIMATION, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnPlayerAnimation(a_Player, a_Animation);
- }
+ return GenericCallHook(
+ HOOK_PLAYER_ANIMATION,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnPlayerAnimation(a_Player, a_Animation); }
);
}
@@ -710,11 +759,27 @@ bool cPluginManager::CallHookPlayerAnimation(cPlayer & a_Player, int a_Animation
-bool cPluginManager::CallHookPlayerBreakingBlock(cPlayer & a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
+bool cPluginManager::CallHookPlayerBreakingBlock(
+ cPlayer & a_Player,
+ Vector3i a_BlockPos,
+ eBlockFace a_BlockFace,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta
+)
{
- return GenericCallHook(HOOK_PLAYER_BREAKING_BLOCK, [&](cPlugin * a_Plugin)
+ return GenericCallHook(
+ HOOK_PLAYER_BREAKING_BLOCK,
+ [&](cPlugin * a_Plugin)
{
- return a_Plugin->OnPlayerBreakingBlock(a_Player, a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, a_BlockFace, a_BlockType, a_BlockMeta);
+ return a_Plugin->OnPlayerBreakingBlock(
+ a_Player,
+ a_BlockPos.x,
+ a_BlockPos.y,
+ a_BlockPos.z,
+ a_BlockFace,
+ a_BlockType,
+ a_BlockMeta
+ );
}
);
}
@@ -723,11 +788,27 @@ bool cPluginManager::CallHookPlayerBreakingBlock(cPlayer & a_Player, Vector3i a_
-bool cPluginManager::CallHookPlayerBrokenBlock(cPlayer & a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
+bool cPluginManager::CallHookPlayerBrokenBlock(
+ cPlayer & a_Player,
+ Vector3i a_BlockPos,
+ eBlockFace a_BlockFace,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta
+)
{
- return GenericCallHook(HOOK_PLAYER_BROKEN_BLOCK, [&](cPlugin * a_Plugin)
+ return GenericCallHook(
+ HOOK_PLAYER_BROKEN_BLOCK,
+ [&](cPlugin * a_Plugin)
{
- return a_Plugin->OnPlayerBrokenBlock(a_Player, a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, a_BlockFace, a_BlockType, a_BlockMeta);
+ return a_Plugin->OnPlayerBrokenBlock(
+ a_Player,
+ a_BlockPos.x,
+ a_BlockPos.y,
+ a_BlockPos.z,
+ a_BlockFace,
+ a_BlockType,
+ a_BlockMeta
+ );
}
);
}
@@ -738,10 +819,9 @@ bool cPluginManager::CallHookPlayerBrokenBlock(cPlayer & a_Player, Vector3i a_Bl
bool cPluginManager::CallHookPlayerDestroyed(cPlayer & a_Player)
{
- return GenericCallHook(HOOK_PLAYER_DESTROYED, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnPlayerDestroyed(a_Player);
- }
+ return GenericCallHook(
+ HOOK_PLAYER_DESTROYED,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnPlayerDestroyed(a_Player); }
);
}
@@ -751,11 +831,7 @@ bool cPluginManager::CallHookPlayerDestroyed(cPlayer & a_Player)
bool cPluginManager::CallHookPlayerEating(cPlayer & a_Player)
{
- return GenericCallHook(HOOK_PLAYER_EATING, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnPlayerEating(a_Player);
- }
- );
+ return GenericCallHook(HOOK_PLAYER_EATING, [&](cPlugin * a_Plugin) { return a_Plugin->OnPlayerEating(a_Player); });
}
@@ -764,10 +840,9 @@ bool cPluginManager::CallHookPlayerEating(cPlayer & a_Player)
bool cPluginManager::CallHookPlayerFoodLevelChange(cPlayer & a_Player, int a_NewFoodLevel)
{
- return GenericCallHook(HOOK_PLAYER_FOOD_LEVEL_CHANGE, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnPlayerFoodLevelChange(a_Player, a_NewFoodLevel);
- }
+ return GenericCallHook(
+ HOOK_PLAYER_FOOD_LEVEL_CHANGE,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnPlayerFoodLevelChange(a_Player, a_NewFoodLevel); }
);
}
@@ -777,10 +852,9 @@ bool cPluginManager::CallHookPlayerFoodLevelChange(cPlayer & a_Player, int a_New
bool cPluginManager::CallHookPlayerFished(cPlayer & a_Player, const cItems & a_Reward, const int ExperienceAmount)
{
- return GenericCallHook(HOOK_PLAYER_FISHED, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnPlayerFished(a_Player, a_Reward, ExperienceAmount);
- }
+ return GenericCallHook(
+ HOOK_PLAYER_FISHED,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnPlayerFished(a_Player, a_Reward, ExperienceAmount); }
);
}
@@ -790,10 +864,9 @@ bool cPluginManager::CallHookPlayerFished(cPlayer & a_Player, const cItems & a_R
bool cPluginManager::CallHookPlayerFishing(cPlayer & a_Player, cItems & a_Reward, int & ExperienceAmount)
{
- return GenericCallHook(HOOK_PLAYER_FISHING, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnPlayerFishing(a_Player, a_Reward, ExperienceAmount);
- }
+ return GenericCallHook(
+ HOOK_PLAYER_FISHING,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnPlayerFishing(a_Player, a_Reward, ExperienceAmount); }
);
}
@@ -803,22 +876,26 @@ bool cPluginManager::CallHookPlayerFishing(cPlayer & a_Player, cItems & a_Reward
bool cPluginManager::CallHookPlayerJoined(cPlayer & a_Player)
{
- return GenericCallHook(HOOK_PLAYER_JOINED, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnPlayerJoined(a_Player);
- }
- );
+ return GenericCallHook(HOOK_PLAYER_JOINED, [&](cPlugin * a_Plugin) { return a_Plugin->OnPlayerJoined(a_Player); });
}
-bool cPluginManager::CallHookPlayerLeftClick(cPlayer & a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, char a_Status)
+bool cPluginManager::CallHookPlayerLeftClick(
+ cPlayer & a_Player,
+ Vector3i a_BlockPos,
+ eBlockFace a_BlockFace,
+ char a_Status
+)
{
- return GenericCallHook(HOOK_PLAYER_LEFT_CLICK, [&](cPlugin * a_Plugin)
+ return GenericCallHook(
+ HOOK_PLAYER_LEFT_CLICK,
+ [&](cPlugin * a_Plugin)
{
- return a_Plugin->OnPlayerLeftClick(a_Player, a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, a_BlockFace, a_Status);
+ return a_Plugin
+ ->OnPlayerLeftClick(a_Player, a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, a_BlockFace, a_Status);
}
);
}
@@ -827,12 +904,17 @@ bool cPluginManager::CallHookPlayerLeftClick(cPlayer & a_Player, Vector3i a_Bloc
-bool cPluginManager::CallHookPlayerMoving(cPlayer & a_Player, const Vector3d & a_OldPosition, const Vector3d & a_NewPosition, bool a_PreviousIsOnGround)
+bool cPluginManager::CallHookPlayerMoving(
+ cPlayer & a_Player,
+ const Vector3d & a_OldPosition,
+ const Vector3d & a_NewPosition,
+ bool a_PreviousIsOnGround
+)
{
- return GenericCallHook(HOOK_PLAYER_MOVING, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnPlayerMoving(a_Player, a_OldPosition, a_NewPosition, a_PreviousIsOnGround);
- }
+ return GenericCallHook(
+ HOOK_PLAYER_MOVING,
+ [&](cPlugin * a_Plugin)
+ { return a_Plugin->OnPlayerMoving(a_Player, a_OldPosition, a_NewPosition, a_PreviousIsOnGround); }
);
}
@@ -842,10 +924,9 @@ bool cPluginManager::CallHookPlayerMoving(cPlayer & a_Player, const Vector3d & a
bool cPluginManager::CallHookPlayerOpeningWindow(cPlayer & a_Player, cWindow & a_Window)
{
- return GenericCallHook(HOOK_PLAYER_OPENING_WINDOW, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnPlayerOpeningWindow(a_Player, a_Window);
- }
+ return GenericCallHook(
+ HOOK_PLAYER_OPENING_WINDOW,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnPlayerOpeningWindow(a_Player, a_Window); }
);
}
@@ -855,10 +936,9 @@ bool cPluginManager::CallHookPlayerOpeningWindow(cPlayer & a_Player, cWindow & a
bool cPluginManager::CallHookPlayerPlacedBlock(cPlayer & a_Player, const sSetBlock & a_BlockChange)
{
- return GenericCallHook(HOOK_PLAYER_PLACED_BLOCK, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnPlayerPlacedBlock(a_Player, a_BlockChange);
- }
+ return GenericCallHook(
+ HOOK_PLAYER_PLACED_BLOCK,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnPlayerPlacedBlock(a_Player, a_BlockChange); }
);
}
@@ -868,10 +948,9 @@ bool cPluginManager::CallHookPlayerPlacedBlock(cPlayer & a_Player, const sSetBlo
bool cPluginManager::CallHookPlayerPlacingBlock(cPlayer & a_Player, const sSetBlock & a_BlockChange)
{
- return GenericCallHook(HOOK_PLAYER_PLACING_BLOCK, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnPlayerPlacingBlock(a_Player, a_BlockChange);
- }
+ return GenericCallHook(
+ HOOK_PLAYER_PLACING_BLOCK,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnPlayerPlacingBlock(a_Player, a_BlockChange); }
);
}
@@ -881,10 +960,9 @@ bool cPluginManager::CallHookPlayerPlacingBlock(cPlayer & a_Player, const sSetBl
bool cPluginManager::CallHookPlayerCrouched(cPlayer & a_Player)
{
- return GenericCallHook(HOOK_PLAYER_CROUCHED, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnPlayerCrouched(a_Player);
- }
+ return GenericCallHook(
+ HOOK_PLAYER_CROUCHED,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnPlayerCrouched(a_Player); }
);
}
@@ -892,11 +970,27 @@ bool cPluginManager::CallHookPlayerCrouched(cPlayer & a_Player)
-bool cPluginManager::CallHookPlayerRightClick(cPlayer & a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, Vector3i a_CursorPos)
+bool cPluginManager::CallHookPlayerRightClick(
+ cPlayer & a_Player,
+ Vector3i a_BlockPos,
+ eBlockFace a_BlockFace,
+ Vector3i a_CursorPos
+)
{
- return GenericCallHook(HOOK_PLAYER_RIGHT_CLICK, [&](cPlugin * a_Plugin)
+ return GenericCallHook(
+ HOOK_PLAYER_RIGHT_CLICK,
+ [&](cPlugin * a_Plugin)
{
- return a_Plugin->OnPlayerRightClick(a_Player, a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, a_BlockFace, a_CursorPos.x, a_CursorPos.y, a_CursorPos.z);
+ return a_Plugin->OnPlayerRightClick(
+ a_Player,
+ a_BlockPos.x,
+ a_BlockPos.y,
+ a_BlockPos.z,
+ a_BlockFace,
+ a_CursorPos.x,
+ a_CursorPos.y,
+ a_CursorPos.z
+ );
}
);
}
@@ -907,10 +1001,9 @@ bool cPluginManager::CallHookPlayerRightClick(cPlayer & a_Player, Vector3i a_Blo
bool cPluginManager::CallHookPlayerRightClickingEntity(cPlayer & a_Player, cEntity & a_Entity)
{
- return GenericCallHook(HOOK_PLAYER_RIGHT_CLICKING_ENTITY, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnPlayerRightClickingEntity(a_Player, a_Entity);
- }
+ return GenericCallHook(
+ HOOK_PLAYER_RIGHT_CLICKING_ENTITY,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnPlayerRightClickingEntity(a_Player, a_Entity); }
);
}
@@ -920,10 +1013,9 @@ bool cPluginManager::CallHookPlayerRightClickingEntity(cPlayer & a_Player, cEnti
bool cPluginManager::CallHookPlayerShooting(cPlayer & a_Player)
{
- return GenericCallHook(HOOK_PLAYER_SHOOTING, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnPlayerShooting(a_Player);
- }
+ return GenericCallHook(
+ HOOK_PLAYER_SHOOTING,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnPlayerShooting(a_Player); }
);
}
@@ -933,10 +1025,9 @@ bool cPluginManager::CallHookPlayerShooting(cPlayer & a_Player)
bool cPluginManager::CallHookPlayerSpawned(cPlayer & a_Player)
{
- return GenericCallHook(HOOK_PLAYER_SPAWNED, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnPlayerSpawned(a_Player);
- }
+ return GenericCallHook(
+ HOOK_PLAYER_SPAWNED,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnPlayerSpawned(a_Player); }
);
}
@@ -946,10 +1037,9 @@ bool cPluginManager::CallHookPlayerSpawned(cPlayer & a_Player)
bool cPluginManager::CallHookPlayerTossingItem(cPlayer & a_Player)
{
- return GenericCallHook(HOOK_PLAYER_TOSSING_ITEM, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnPlayerTossingItem(a_Player);
- }
+ return GenericCallHook(
+ HOOK_PLAYER_TOSSING_ITEM,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnPlayerTossingItem(a_Player); }
);
}
@@ -957,11 +1047,31 @@ bool cPluginManager::CallHookPlayerTossingItem(cPlayer & a_Player)
-bool cPluginManager::CallHookPlayerUsedBlock(cPlayer & a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, Vector3i a_CursorPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
+bool cPluginManager::CallHookPlayerUsedBlock(
+ cPlayer & a_Player,
+ Vector3i a_BlockPos,
+ eBlockFace a_BlockFace,
+ Vector3i a_CursorPos,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta
+)
{
- return GenericCallHook(HOOK_PLAYER_USED_BLOCK, [&](cPlugin * a_Plugin)
+ return GenericCallHook(
+ HOOK_PLAYER_USED_BLOCK,
+ [&](cPlugin * a_Plugin)
{
- return a_Plugin->OnPlayerUsedBlock(a_Player, a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, a_BlockFace, a_CursorPos.x, a_CursorPos.y, a_CursorPos.z, a_BlockType, a_BlockMeta);
+ return a_Plugin->OnPlayerUsedBlock(
+ a_Player,
+ a_BlockPos.x,
+ a_BlockPos.y,
+ a_BlockPos.z,
+ a_BlockFace,
+ a_CursorPos.x,
+ a_CursorPos.y,
+ a_CursorPos.z,
+ a_BlockType,
+ a_BlockMeta
+ );
}
);
}
@@ -970,11 +1080,27 @@ bool cPluginManager::CallHookPlayerUsedBlock(cPlayer & a_Player, Vector3i a_Bloc
-bool cPluginManager::CallHookPlayerUsedItem(cPlayer & a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, Vector3i a_CursorPos)
+bool cPluginManager::CallHookPlayerUsedItem(
+ cPlayer & a_Player,
+ Vector3i a_BlockPos,
+ eBlockFace a_BlockFace,
+ Vector3i a_CursorPos
+)
{
- return GenericCallHook(HOOK_PLAYER_USED_ITEM, [&](cPlugin * a_Plugin)
+ return GenericCallHook(
+ HOOK_PLAYER_USED_ITEM,
+ [&](cPlugin * a_Plugin)
{
- return a_Plugin->OnPlayerUsedItem(a_Player, a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, a_BlockFace, a_CursorPos.x, a_CursorPos.y, a_CursorPos.z);
+ return a_Plugin->OnPlayerUsedItem(
+ a_Player,
+ a_BlockPos.x,
+ a_BlockPos.y,
+ a_BlockPos.z,
+ a_BlockFace,
+ a_CursorPos.x,
+ a_CursorPos.y,
+ a_CursorPos.z
+ );
}
);
}
@@ -983,11 +1109,31 @@ bool cPluginManager::CallHookPlayerUsedItem(cPlayer & a_Player, Vector3i a_Block
-bool cPluginManager::CallHookPlayerUsingBlock(cPlayer & a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, Vector3i a_CursorPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
+bool cPluginManager::CallHookPlayerUsingBlock(
+ cPlayer & a_Player,
+ Vector3i a_BlockPos,
+ eBlockFace a_BlockFace,
+ Vector3i a_CursorPos,
+ BLOCKTYPE a_BlockType,
+ NIBBLETYPE a_BlockMeta
+)
{
- return GenericCallHook(HOOK_PLAYER_USING_BLOCK, [&](cPlugin * a_Plugin)
+ return GenericCallHook(
+ HOOK_PLAYER_USING_BLOCK,
+ [&](cPlugin * a_Plugin)
{
- return a_Plugin->OnPlayerUsingBlock(a_Player, a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, a_BlockFace, a_CursorPos.x, a_CursorPos.y, a_CursorPos.z, a_BlockType, a_BlockMeta);
+ return a_Plugin->OnPlayerUsingBlock(
+ a_Player,
+ a_BlockPos.x,
+ a_BlockPos.y,
+ a_BlockPos.z,
+ a_BlockFace,
+ a_CursorPos.x,
+ a_CursorPos.y,
+ a_CursorPos.z,
+ a_BlockType,
+ a_BlockMeta
+ );
}
);
}
@@ -996,11 +1142,27 @@ bool cPluginManager::CallHookPlayerUsingBlock(cPlayer & a_Player, Vector3i a_Blo
-bool cPluginManager::CallHookPlayerUsingItem(cPlayer & a_Player, Vector3i a_BlockPos, eBlockFace a_BlockFace, Vector3i a_CursorPos)
+bool cPluginManager::CallHookPlayerUsingItem(
+ cPlayer & a_Player,
+ Vector3i a_BlockPos,
+ eBlockFace a_BlockFace,
+ Vector3i a_CursorPos
+)
{
- return GenericCallHook(HOOK_PLAYER_USING_ITEM, [&](cPlugin * a_Plugin)
+ return GenericCallHook(
+ HOOK_PLAYER_USING_ITEM,
+ [&](cPlugin * a_Plugin)
{
- return a_Plugin->OnPlayerUsingItem(a_Player, a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, a_BlockFace, a_CursorPos.x, a_CursorPos.y, a_CursorPos.z);
+ return a_Plugin->OnPlayerUsingItem(
+ a_Player,
+ a_BlockPos.x,
+ a_BlockPos.y,
+ a_BlockPos.z,
+ a_BlockFace,
+ a_CursorPos.x,
+ a_CursorPos.y,
+ a_CursorPos.z
+ );
}
);
}
@@ -1009,12 +1171,15 @@ bool cPluginManager::CallHookPlayerUsingItem(cPlayer & a_Player, Vector3i a_Bloc
-bool cPluginManager::CallHookPluginMessage(cClientHandle & a_Client, const AString & a_Channel, const ContiguousByteBufferView a_Message)
+bool cPluginManager::CallHookPluginMessage(
+ cClientHandle & a_Client,
+ const AString & a_Channel,
+ const ContiguousByteBufferView a_Message
+)
{
- return GenericCallHook(HOOK_PLUGIN_MESSAGE, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnPluginMessage(a_Client, a_Channel, a_Message);
- }
+ return GenericCallHook(
+ HOOK_PLUGIN_MESSAGE,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnPluginMessage(a_Client, a_Channel, a_Message); }
);
}
@@ -1047,10 +1212,9 @@ bool cPluginManager::CallHookPluginsLoaded(void)
bool cPluginManager::CallHookPostCrafting(cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe & a_Recipe)
{
- return GenericCallHook(HOOK_POST_CRAFTING, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnPostCrafting(a_Player, a_Grid, a_Recipe);
- }
+ return GenericCallHook(
+ HOOK_POST_CRAFTING,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnPostCrafting(a_Player, a_Grid, a_Recipe); }
);
}
@@ -1060,10 +1224,9 @@ bool cPluginManager::CallHookPostCrafting(cPlayer & a_Player, cCraftingGrid & a_
bool cPluginManager::CallHookPreCrafting(cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe & a_Recipe)
{
- return GenericCallHook(HOOK_PRE_CRAFTING, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnPreCrafting(a_Player, a_Grid, a_Recipe);
- }
+ return GenericCallHook(
+ HOOK_PRE_CRAFTING,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnPreCrafting(a_Player, a_Grid, a_Recipe); }
);
}
@@ -1071,11 +1234,19 @@ bool cPluginManager::CallHookPreCrafting(cPlayer & a_Player, cCraftingGrid & a_G
-bool cPluginManager::CallHookProjectileHitBlock(cProjectileEntity & a_Projectile, Vector3i a_BlockPos, eBlockFace a_Face, const Vector3d & a_BlockHitPos)
+bool cPluginManager::CallHookProjectileHitBlock(
+ cProjectileEntity & a_Projectile,
+ Vector3i a_BlockPos,
+ eBlockFace a_Face,
+ const Vector3d & a_BlockHitPos
+)
{
- return GenericCallHook(HOOK_PROJECTILE_HIT_BLOCK, [&](cPlugin * a_Plugin)
+ return GenericCallHook(
+ HOOK_PROJECTILE_HIT_BLOCK,
+ [&](cPlugin * a_Plugin)
{
- return a_Plugin->OnProjectileHitBlock(a_Projectile, a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, a_Face, a_BlockHitPos);
+ return a_Plugin
+ ->OnProjectileHitBlock(a_Projectile, a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, a_Face, a_BlockHitPos);
}
);
}
@@ -1086,10 +1257,9 @@ bool cPluginManager::CallHookProjectileHitBlock(cProjectileEntity & a_Projectile
bool cPluginManager::CallHookProjectileHitEntity(cProjectileEntity & a_Projectile, cEntity & a_HitEntity)
{
- return GenericCallHook(HOOK_PROJECTILE_HIT_ENTITY, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnProjectileHitEntity(a_Projectile, a_HitEntity);
- }
+ return GenericCallHook(
+ HOOK_PROJECTILE_HIT_ENTITY,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnProjectileHitEntity(a_Projectile, a_HitEntity); }
);
}
@@ -1097,11 +1267,20 @@ bool cPluginManager::CallHookProjectileHitEntity(cProjectileEntity & a_Projectil
-bool cPluginManager::CallHookServerPing(cClientHandle & a_ClientHandle, AString & a_ServerDescription, int & a_OnlinePlayersCount, int & a_MaxPlayersCount, AString & a_Favicon)
+bool cPluginManager::CallHookServerPing(
+ cClientHandle & a_ClientHandle,
+ AString & a_ServerDescription,
+ int & a_OnlinePlayersCount,
+ int & a_MaxPlayersCount,
+ AString & a_Favicon
+)
{
- return GenericCallHook(HOOK_SERVER_PING, [&](cPlugin * a_Plugin)
+ return GenericCallHook(
+ HOOK_SERVER_PING,
+ [&](cPlugin * a_Plugin)
{
- return a_Plugin->OnServerPing(a_ClientHandle, a_ServerDescription, a_OnlinePlayersCount, a_MaxPlayersCount, a_Favicon);
+ return a_Plugin
+ ->OnServerPing(a_ClientHandle, a_ServerDescription, a_OnlinePlayersCount, a_MaxPlayersCount, a_Favicon);
}
);
}
@@ -1112,10 +1291,9 @@ bool cPluginManager::CallHookServerPing(cClientHandle & a_ClientHandle, AString
bool cPluginManager::CallHookSpawnedEntity(cWorld & a_World, cEntity & a_Entity)
{
- return GenericCallHook(HOOK_SPAWNED_ENTITY, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnSpawnedEntity(a_World, a_Entity);
- }
+ return GenericCallHook(
+ HOOK_SPAWNED_ENTITY,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnSpawnedEntity(a_World, a_Entity); }
);
}
@@ -1125,10 +1303,9 @@ bool cPluginManager::CallHookSpawnedEntity(cWorld & a_World, cEntity & a_Entity)
bool cPluginManager::CallHookSpawnedMonster(cWorld & a_World, cMonster & a_Monster)
{
- return GenericCallHook(HOOK_SPAWNED_MONSTER, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnSpawnedMonster(a_World, a_Monster);
- }
+ return GenericCallHook(
+ HOOK_SPAWNED_MONSTER,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnSpawnedMonster(a_World, a_Monster); }
);
}
@@ -1138,10 +1315,9 @@ bool cPluginManager::CallHookSpawnedMonster(cWorld & a_World, cMonster & a_Monst
bool cPluginManager::CallHookSpawningEntity(cWorld & a_World, cEntity & a_Entity)
{
- return GenericCallHook(HOOK_SPAWNING_ENTITY, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnSpawningEntity(a_World, a_Entity);
- }
+ return GenericCallHook(
+ HOOK_SPAWNING_ENTITY,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnSpawningEntity(a_World, a_Entity); }
);
}
@@ -1151,10 +1327,9 @@ bool cPluginManager::CallHookSpawningEntity(cWorld & a_World, cEntity & a_Entity
bool cPluginManager::CallHookSpawningMonster(cWorld & a_World, cMonster & a_Monster)
{
- return GenericCallHook(HOOK_SPAWNING_MONSTER, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnSpawningMonster(a_World, a_Monster);
- }
+ return GenericCallHook(
+ HOOK_SPAWNING_MONSTER,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnSpawningMonster(a_World, a_Monster); }
);
}
@@ -1164,10 +1339,9 @@ bool cPluginManager::CallHookSpawningMonster(cWorld & a_World, cMonster & a_Mons
bool cPluginManager::CallHookTakeDamage(cEntity & a_Receiver, TakeDamageInfo & a_TDI)
{
- return GenericCallHook(HOOK_TAKE_DAMAGE, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnTakeDamage(a_Receiver, a_TDI);
- }
+ return GenericCallHook(
+ HOOK_TAKE_DAMAGE,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnTakeDamage(a_Receiver, a_TDI); }
);
}
@@ -1175,11 +1349,31 @@ bool cPluginManager::CallHookTakeDamage(cEntity & a_Receiver, TakeDamageInfo & a
-bool cPluginManager::CallHookUpdatingSign(cWorld & a_World, Vector3i a_BlockPos, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4, cPlayer * a_Player)
+bool cPluginManager::CallHookUpdatingSign(
+ cWorld & a_World,
+ Vector3i a_BlockPos,
+ AString & a_Line1,
+ AString & a_Line2,
+ AString & a_Line3,
+ AString & a_Line4,
+ cPlayer * a_Player
+)
{
- return GenericCallHook(HOOK_UPDATING_SIGN, [&](cPlugin * a_Plugin)
+ return GenericCallHook(
+ HOOK_UPDATING_SIGN,
+ [&](cPlugin * a_Plugin)
{
- return a_Plugin->OnUpdatingSign(a_World, a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, a_Line1, a_Line2, a_Line3, a_Line4, a_Player);
+ return a_Plugin->OnUpdatingSign(
+ a_World,
+ a_BlockPos.x,
+ a_BlockPos.y,
+ a_BlockPos.z,
+ a_Line1,
+ a_Line2,
+ a_Line3,
+ a_Line4,
+ a_Player
+ );
}
);
}
@@ -1188,11 +1382,31 @@ bool cPluginManager::CallHookUpdatingSign(cWorld & a_World, Vector3i a_BlockPos,
-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)
+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
+)
{
- return GenericCallHook(HOOK_UPDATED_SIGN, [&](cPlugin * a_Plugin)
+ return GenericCallHook(
+ HOOK_UPDATED_SIGN,
+ [&](cPlugin * a_Plugin)
{
- return a_Plugin->OnUpdatedSign(a_World, a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, a_Line1, a_Line2, a_Line3, a_Line4, a_Player);
+ return a_Plugin->OnUpdatedSign(
+ a_World,
+ a_BlockPos.x,
+ a_BlockPos.y,
+ a_BlockPos.z,
+ a_Line1,
+ a_Line2,
+ a_Line3,
+ a_Line4,
+ a_Player
+ );
}
);
}
@@ -1203,10 +1417,9 @@ bool cPluginManager::CallHookUpdatedSign(cWorld & a_World, Vector3i a_BlockPos,
bool cPluginManager::CallHookWeatherChanged(cWorld & a_World)
{
- return GenericCallHook(HOOK_WEATHER_CHANGED, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnWeatherChanged(a_World);
- }
+ return GenericCallHook(
+ HOOK_WEATHER_CHANGED,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnWeatherChanged(a_World); }
);
}
@@ -1216,10 +1429,9 @@ bool cPluginManager::CallHookWeatherChanged(cWorld & a_World)
bool cPluginManager::CallHookWeatherChanging(cWorld & a_World, eWeather & a_NewWeather)
{
- return GenericCallHook(HOOK_WEATHER_CHANGING, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnWeatherChanging(a_World, a_NewWeather);
- }
+ return GenericCallHook(
+ HOOK_WEATHER_CHANGING,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnWeatherChanging(a_World, a_NewWeather); }
);
}
@@ -1229,23 +1441,22 @@ bool cPluginManager::CallHookWeatherChanging(cWorld & a_World, eWeather & a_NewW
bool cPluginManager::CallHookWorldStarted(cWorld & a_World)
{
- return GenericCallHook(HOOK_WORLD_STARTED, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnWorldStarted(a_World);
- }
- );
+ return GenericCallHook(HOOK_WORLD_STARTED, [&](cPlugin * a_Plugin) { return a_Plugin->OnWorldStarted(a_World); });
}
-bool cPluginManager::CallHookWorldTick(cWorld & a_World, std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_LastTickDurationMSec)
+bool cPluginManager::CallHookWorldTick(
+ cWorld & a_World,
+ std::chrono::milliseconds a_Dt,
+ std::chrono::milliseconds a_LastTickDurationMSec
+)
{
- return GenericCallHook(HOOK_WORLD_TICK, [&](cPlugin * a_Plugin)
- {
- return a_Plugin->OnWorldTick(a_World, a_Dt, a_LastTickDurationMSec);
- }
+ return GenericCallHook(
+ HOOK_WORLD_TICK,
+ [&](cPlugin * a_Plugin) { return a_Plugin->OnWorldTick(a_World, a_Dt, a_LastTickDurationMSec); }
);
}
@@ -1253,7 +1464,11 @@ bool cPluginManager::CallHookWorldTick(cWorld & a_World, std::chrono::millisecon
-cPluginManager::CommandResult cPluginManager::HandleCommand(cPlayer & a_Player, const AString & a_Command, bool a_ShouldCheckPermissions)
+cPluginManager::CommandResult cPluginManager::HandleCommand(
+ cPlayer & a_Player,
+ const AString & a_Command,
+ bool a_ShouldCheckPermissions
+)
{
AStringVector Split(StringSplit(a_Command, " "));
if (Split.empty())
@@ -1281,16 +1496,17 @@ cPluginManager::CommandResult cPluginManager::HandleCommand(cPlayer & a_Player,
{
if (Result == crBlocked)
{
- LOGINFO("Player %s tried executing command \"%s\" that was stopped by the HOOK_EXECUTE_COMMAND hook", a_Player.GetName().c_str(), Split[0].c_str());
+ LOGINFO(
+ "Player %s tried executing command \"%s\" that was stopped by the HOOK_EXECUTE_COMMAND hook",
+ a_Player.GetName().c_str(),
+ Split[0].c_str()
+ );
}
return Result;
}
- if (
- a_ShouldCheckPermissions &&
- !cmd->second.m_Permission.empty() &&
- !a_Player.HasPermission(cmd->second.m_Permission)
- )
+ if (a_ShouldCheckPermissions && !cmd->second.m_Permission.empty() &&
+ !a_Player.HasPermission(cmd->second.m_Permission))
{
LOGINFO("Player %s tried to execute forbidden command: \"%s\"", a_Player.GetName().c_str(), Split[0].c_str());
return crNoPermission;
@@ -1321,7 +1537,7 @@ void cPluginManager::UnloadPluginsNow()
cServer::BindBuiltInConsoleCommands();
// Unload all loaded plugins:
- for (auto & plugin: m_Plugins)
+ for (auto & plugin : m_Plugins)
{
if (plugin->IsLoaded())
{
@@ -1356,7 +1572,7 @@ void cPluginManager::ReloadPlugin(const AString & a_PluginFolder)
bool cPluginManager::LoadPlugin(const AString & a_FolderName)
{
- for (auto & plugin: m_Plugins)
+ for (auto & plugin : m_Plugins)
{
if (plugin->GetFolderName() == a_FolderName)
{
@@ -1395,7 +1611,8 @@ void cPluginManager::RemovePluginCommands(cPlugin * a_Plugin)
{
if (itr->second.m_Plugin == a_Plugin)
{
- CommandMap::iterator EraseMe = itr; // Stupid GCC doesn't have a std::map::erase() that would return the next iterator
+ CommandMap::iterator EraseMe =
+ itr; // Stupid GCC doesn't have a std::map::erase() that would return the next iterator
++itr;
m_Commands.erase(EraseMe);
}
@@ -1412,7 +1629,7 @@ void cPluginManager::RemovePluginCommands(cPlugin * a_Plugin)
bool cPluginManager::IsPluginLoaded(const AString & a_PluginName)
{
- for (auto & plugin: m_Plugins)
+ for (auto & plugin : m_Plugins)
{
if (plugin->GetName() == a_PluginName)
{
@@ -1437,13 +1654,17 @@ bool cPluginManager::BindCommand(
CommandMap::iterator cmd = m_Commands.find(a_Command);
if (cmd != m_Commands.end())
{
- LOGWARNING("Command \"%s\" is already bound to plugin \"%s\".", a_Command.c_str(), cmd->second.m_Plugin->GetName().c_str());
+ LOGWARNING(
+ "Command \"%s\" is already bound to plugin \"%s\".",
+ a_Command.c_str(),
+ cmd->second.m_Plugin->GetName().c_str()
+ );
return false;
}
auto & reg = m_Commands[a_Command];
- reg.m_Plugin = a_Plugin;
- reg.m_Handler = std::move(a_Handler);
+ reg.m_Plugin = a_Plugin;
+ reg.m_Handler = std::move(a_Handler);
reg.m_Permission = a_Permission;
reg.m_HelpString = a_HelpString;
return true;
@@ -1512,7 +1733,8 @@ void cPluginManager::RemovePluginConsoleCommands(cPlugin * a_Plugin)
{
if (itr->second.m_Plugin == a_Plugin)
{
- CommandMap::iterator EraseMe = itr; // Stupid GCC doesn't have a std::map::erase() that would return the next iterator
+ CommandMap::iterator EraseMe =
+ itr; // Stupid GCC doesn't have a std::map::erase() that would return the next iterator
++itr;
m_ConsoleCommands.erase(EraseMe);
}
@@ -1539,18 +1761,27 @@ bool cPluginManager::BindConsoleCommand(
{
if (cmd->second.m_Plugin == nullptr)
{
- LOGWARNING("Console command \"%s\" is already bound internally by Cuberite, cannot bind in plugin \"%s\".", a_Command.c_str(), a_Plugin->GetName().c_str());
+ LOGWARNING(
+ "Console command \"%s\" is already bound internally by Cuberite, cannot bind in plugin \"%s\".",
+ a_Command.c_str(),
+ a_Plugin->GetName().c_str()
+ );
}
else
{
- LOGWARNING("Console command \"%s\" is already bound to plugin \"%s\", cannot bind in plugin \"%s\".", a_Command.c_str(), cmd->second.m_Plugin->GetName().c_str(), a_Plugin->GetName().c_str());
+ LOGWARNING(
+ "Console command \"%s\" is already bound to plugin \"%s\", cannot bind in plugin \"%s\".",
+ a_Command.c_str(),
+ cmd->second.m_Plugin->GetName().c_str(),
+ a_Plugin->GetName().c_str()
+ );
}
return false;
}
auto & reg = m_ConsoleCommands[a_Command];
- reg.m_Plugin = a_Plugin;
- reg.m_Handler = std::move(a_Handler);
+ reg.m_Plugin = a_Plugin;
+ reg.m_Handler = std::move(a_Handler);
reg.m_Permission = "";
reg.m_HelpString = a_HelpString;
return true;
@@ -1585,7 +1816,11 @@ bool cPluginManager::IsConsoleCommandBound(const AString & a_Command)
-bool cPluginManager::ExecuteConsoleCommand(const AStringVector & a_Split, cCommandOutputCallback & a_Output, const AString & a_Command)
+bool cPluginManager::ExecuteConsoleCommand(
+ const AStringVector & a_Split,
+ cCommandOutputCallback & a_Output,
+ const AString & a_Command
+)
{
if (a_Split.empty())
{
@@ -1676,7 +1911,7 @@ bool cPluginManager::IsValidHookType(int a_HookType)
bool cPluginManager::DoWithPlugin(const AString & a_PluginName, cPluginCallback a_Callback)
{
// TODO: Implement locking for plugins
- for (auto & plugin: m_Plugins)
+ for (auto & plugin : m_Plugins)
{
if (plugin->GetName() == a_PluginName)
{
@@ -1693,7 +1928,7 @@ bool cPluginManager::DoWithPlugin(const AString & a_PluginName, cPluginCallback
bool cPluginManager::ForEachPlugin(cPluginCallback a_Callback)
{
// TODO: Implement locking for plugins
- for (auto & plugin: m_Plugins)
+ for (auto & plugin : m_Plugins)
{
if (a_Callback(*plugin))
{
@@ -1710,7 +1945,7 @@ bool cPluginManager::ForEachPlugin(cPluginCallback a_Callback)
AString cPluginManager::GetPluginFolderName(const AString & a_PluginName)
{
// TODO: Implement locking for plugins
- for (auto & plugin: m_Plugins)
+ for (auto & plugin : m_Plugins)
{
if (plugin->GetName() == a_PluginName)
{
@@ -1754,7 +1989,7 @@ size_t cPluginManager::GetNumPlugins(void) const
size_t cPluginManager::GetNumLoadedPlugins(void) const
{
size_t res = 0;
- for (auto & plugin: m_Plugins)
+ for (auto & plugin : m_Plugins)
{
if (plugin->IsLoaded())
{
@@ -1787,11 +2022,7 @@ AStringVector cPluginManager::GetFoldersToLoad(cSettingsRepositoryInterface & a_
if (ValueName.compare("Plugin") == 0)
{
AString PluginFile = NameValue.second;
- if (
- !PluginFile.empty() &&
- (PluginFile != "0") &&
- (PluginFile != "1")
- )
+ if (!PluginFile.empty() && (PluginFile != "0") && (PluginFile != "1"))
{
a_Settings.DeleteValue("Plugins", ValueName);
a_Settings.SetValue("Plugins", PluginFile, "1");
@@ -1812,7 +2043,3 @@ AStringVector cPluginManager::GetFoldersToLoad(cSettingsRepositoryInterface & a_
return res;
}
-
-
-
-