Cuberite
A lightweight, fast and extensible game server for Minecraft
|
#include <PluginLua.h>
Classes | |
class | cOperation |
A RAII-style mutex lock for accessing the internal LuaState. More... | |
Public Member Functions | |
bool | AddHookCallback (int a_HookType, cLuaState::cCallbackPtr &&a_Callback) |
Adds a Lua callback to be called for the specified hook. More... | |
template<typename FnT , typename... Args> | |
bool | Call (FnT a_Fn, Args &&... a_Args) |
Call a Lua function residing in the plugin. More... | |
int | CallFunctionFromForeignState (const AString &a_FunctionName, cLuaState &a_ForeignState, int a_ParamStart, int a_ParamEnd) |
Calls a function in this plugin's LuaState with parameters copied over from a_ForeignState. More... | |
bool | CanAddOldStyleHook (int a_HookType) |
Returns true if the plugin contains the function for the specified hook type, using the old-style registration (#121) More... | |
cPluginLua (const AString &a_PluginDirectory, cDeadlockDetect &a_DeadlockDetect) | |
virtual bool | Load (void) override |
Loads and initializes the plugin. More... | |
virtual bool | OnBlockSpread (cWorld &a_World, int a_BlockX, int a_BlockY, int a_BlockZ, eSpreadSource a_Source) override |
Calls the specified hook with the params given. More... | |
virtual bool | OnBlockToPickups (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) override |
virtual bool | OnBrewingCompleted (cWorld &a_World, cBrewingstandEntity &a_BrewingstandEntity) override |
virtual bool | OnBrewingCompleting (cWorld &a_World, cBrewingstandEntity &a_BrewingstandEntity) override |
virtual bool | OnChat (cPlayer &a_Player, AString &a_Message) override |
virtual bool | OnChunkAvailable (cWorld &a_World, int a_ChunkX, int a_ChunkZ) override |
virtual bool | OnChunkGenerated (cWorld &a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc *a_ChunkDesc) override |
virtual bool | OnChunkGenerating (cWorld &a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc *a_ChunkDesc) override |
virtual bool | OnChunkUnloaded (cWorld &a_World, int a_ChunkX, int a_ChunkZ) override |
virtual bool | OnChunkUnloading (cWorld &a_World, int a_ChunkX, int a_ChunkZ) override |
virtual bool | OnCollectingPickup (cPlayer &a_Player, cPickup &a_Pickup) override |
virtual bool | OnCraftingNoRecipe (cPlayer &a_Player, cCraftingGrid &a_Grid, cCraftingRecipe &a_Recipe) override |
virtual void | OnDisable (void) override |
Called as the last call into the plugin before it is unloaded. More... | |
virtual bool | OnDisconnect (cClientHandle &a_Client, const AString &a_Reason) override |
virtual bool | OnDropSpense (cWorld &a_World, cDropSpenserEntity &a_DropSpenser, int a_SlotNum) override |
virtual bool | OnEntityAddEffect (cEntity &a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier) override |
virtual bool | OnEntityChangedWorld (cEntity &a_Entity, cWorld &a_World) override |
virtual bool | OnEntityChangingWorld (cEntity &a_Entity, cWorld &a_World) override |
virtual bool | OnEntityTeleport (cEntity &a_Entity, const Vector3d &a_OldPosition, const Vector3d &a_NewPosition) override |
virtual bool | OnExecuteCommand (cPlayer *a_Player, const AStringVector &a_Split, const AString &a_EntireCommand, cPluginManager::CommandResult &a_Result) override |
virtual bool | OnExploded (cWorld &a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void *a_SourceData) override |
virtual bool | OnExploding (cWorld &a_World, double &a_ExplosionSize, bool &a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void *a_SourceData) override |
virtual bool | OnHandshake (cClientHandle &a_Client, const AString &a_Username) override |
virtual bool | OnHopperPullingItem (cWorld &a_World, cHopperEntity &a_Hopper, int a_DstSlotNum, cBlockEntityWithItems &a_SrcEntity, int a_SrcSlotNum) override |
virtual bool | OnHopperPushingItem (cWorld &a_World, cHopperEntity &a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems &a_DstEntity, int a_DstSlotNum) override |
virtual bool | OnKilled (cEntity &a_Victim, TakeDamageInfo &a_TDI, AString &a_DeathMessage) override |
virtual bool | OnKilling (cEntity &a_Victim, cEntity *a_Killer, TakeDamageInfo &a_TDI) override |
virtual bool | OnLogin (cClientHandle &a_Client, UInt32 a_ProtocolVersion, const AString &a_Username) override |
virtual bool | OnLoginForge (cClientHandle &a_Client, const AStringMap &a_Mods) override |
virtual bool | OnPlayerAnimation (cPlayer &a_Player, int a_Animation) override |
virtual bool | OnPlayerBreakingBlock (cPlayer &a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override |
virtual bool | OnPlayerBrokenBlock (cPlayer &a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override |
virtual bool | OnPlayerCrouched (cPlayer &a_Player) override |
virtual bool | OnPlayerDestroyed (cPlayer &a_Player) override |
virtual bool | OnPlayerEating (cPlayer &a_Player) override |
virtual bool | OnPlayerFished (cPlayer &a_Player, const cItems &a_Reward, const int ExperienceAmount) override |
virtual bool | OnPlayerFishing (cPlayer &a_Player, cItems &a_Reward, int &ExperienceAmount) override |
virtual bool | OnPlayerFoodLevelChange (cPlayer &a_Player, int a_NewFoodLevel) override |
virtual bool | OnPlayerJoined (cPlayer &a_Player) override |
virtual bool | OnPlayerLeftClick (cPlayer &a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, char a_Status) override |
virtual bool | OnPlayerMoving (cPlayer &a_Player, const Vector3d &a_OldPosition, const Vector3d &a_NewPosition, bool a_PreviousIsOnGround) override |
virtual bool | OnPlayerOpeningWindow (cPlayer &a_Player, cWindow &a_Window) override |
virtual bool | OnPlayerPlacedBlock (cPlayer &a_Player, const sSetBlock &a_BlockChange) override |
virtual bool | OnPlayerPlacingBlock (cPlayer &a_Player, const sSetBlock &a_BlockChange) override |
virtual bool | OnPlayerRightClick (cPlayer &a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override |
virtual bool | OnPlayerRightClickingEntity (cPlayer &a_Player, cEntity &a_Entity) override |
virtual bool | OnPlayerShooting (cPlayer &a_Player) override |
virtual bool | OnPlayerSpawned (cPlayer &a_Player) override |
virtual bool | OnPlayerTossingItem (cPlayer &a_Player) override |
virtual bool | OnPlayerUsedBlock (cPlayer &a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override |
virtual bool | OnPlayerUsedItem (cPlayer &a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override |
virtual bool | OnPlayerUsingBlock (cPlayer &a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override |
virtual bool | OnPlayerUsingItem (cPlayer &a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override |
virtual bool | OnPluginMessage (cClientHandle &a_Client, const AString &a_Channel, ContiguousByteBufferView a_Message) override |
virtual bool | OnPluginsLoaded (void) override |
virtual bool | OnPostCrafting (cPlayer &a_Player, cCraftingGrid &a_Grid, cCraftingRecipe &a_Recipe) override |
virtual bool | OnPreCrafting (cPlayer &a_Player, cCraftingGrid &a_Grid, cCraftingRecipe &a_Recipe) override |
virtual bool | OnProjectileHitBlock (cProjectileEntity &a_Projectile, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Face, const Vector3d &a_BlockHitPos) override |
virtual bool | OnProjectileHitEntity (cProjectileEntity &a_Projectile, cEntity &a_HitEntity) override |
virtual bool | OnServerPing (cClientHandle &a_ClientHandle, AString &a_ServerDescription, int &a_OnlinePlayersCount, int &a_MaxPlayersCount, AString &a_Favicon) override |
virtual bool | OnSpawnedEntity (cWorld &a_World, cEntity &a_Entity) override |
virtual bool | OnSpawnedMonster (cWorld &a_World, cMonster &a_Monster) override |
virtual bool | OnSpawningEntity (cWorld &a_World, cEntity &a_Entity) override |
virtual bool | OnSpawningMonster (cWorld &a_World, cMonster &a_Monster) override |
virtual bool | OnTakeDamage (cEntity &a_Receiver, TakeDamageInfo &a_TakeDamageInfo) override |
virtual bool | OnUpdatedSign (cWorld &a_World, int a_BlockX, int a_BlockY, int a_BlockZ, const AString &a_Line1, const AString &a_Line2, const AString &a_Line3, const AString &a_Line4, cPlayer *a_Player) override |
virtual bool | OnUpdatingSign (cWorld &a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString &a_Line1, AString &a_Line2, AString &a_Line3, AString &a_Line4, cPlayer *a_Player) override |
virtual bool | OnWeatherChanged (cWorld &a_World) override |
virtual bool | OnWeatherChanging (cWorld &a_World, eWeather &a_NewWeather) override |
virtual bool | OnWorldStarted (cWorld &a_World) override |
virtual bool | OnWorldTick (cWorld &a_World, std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_LastTickDurationMSec) override |
virtual void | Tick (float a_Dt) override |
virtual void | Unload (void) override |
Unloads the plugin. More... | |
virtual | ~cPluginLua () override |
Public Member Functions inherited from cPlugin | |
cPlugin (const AString &a_FolderName) | |
Creates a new instance. More... | |
const AString & | GetFolderName (void) const |
Returns the name of the folder (in the Plugins folder) from which the plugin is loaded. More... | |
const AString & | GetLoadError (void) const |
Returns the error encountered while loading the plugin. More... | |
AString | GetLocalFolder (void) const |
Returns the folder relative to the MCS Executable, from which the plugin is loaded. More... | |
const AString & | GetName (void) const |
cPluginManager::ePluginStatus | GetStatus (void) const |
int | GetVersion (void) const |
bool | IsLoaded (void) const |
void | SetName (const AString &a_Name) |
void | SetVersion (int a_Version) |
virtual | ~cPlugin () |
Static Public Member Functions | |
static const char * | GetHookFnName (int a_HookType) |
Returns the name of Lua function that should handle the specified hook type in the older (#121) API. More... | |
Static Public Member Functions inherited from cPlugin | |
static const char * | GetClassStatic (void) |
Protected Types | |
typedef std::map< int, cLuaCallbacks > | cHookMap |
Maps hook types into arrays of Lua function references to call for each hook type. More... | |
typedef std::vector< cLuaState::cCallbackPtr > | cLuaCallbacks |
Provides an array of Lua function references. More... | |
Protected Member Functions | |
template<typename... Args> | |
bool | CallSimpleHooks (int a_HookType, Args &&... a_Args) |
Calls a hook that has the simple format - single bool return value specifying whether the chain should continue. More... | |
void | ClearWebTabs (void) |
Removes all WebTabs currently registered for this plugin from the WebAdmin. More... | |
void | Close (void) |
Releases all Lua references, notifies and removes all m_Resettables[] and closes the m_LuaState. More... | |
Protected Member Functions inherited from cPlugin | |
void | SetLoadError (const AString &a_LoadError) |
Sets m_LoadError to the specified string and m_Status to psError. More... | |
Protected Attributes | |
cDeadlockDetect & | m_DeadlockDetect |
The DeadlockDetect object to which the plugin's CS is tracked. More... | |
cHookMap | m_HookMap |
Hooks that the plugin has registered. More... | |
cLuaState | m_LuaState |
The plugin's Lua state. More... | |
Protected Attributes inherited from cPlugin | |
AString | m_FolderName |
Name of the folder (in the Plugins folder) from which the plugin is loaded. More... | |
AString | m_LoadError |
The error encountered while loading the plugin. More... | |
AString | m_Name |
The name of the plugin, used to identify the plugin in the system and for inter-plugin calls. More... | |
cPluginManager::ePluginStatus | m_Status |
int | m_Version |
Private Types | |
using | Super = cPlugin |
Definition at line 22 of file PluginLua.h.
|
protected |
Maps hook types into arrays of Lua function references to call for each hook type.
Definition at line 170 of file PluginLua.h.
|
protected |
Provides an array of Lua function references.
Definition at line 167 of file PluginLua.h.
|
private |
Definition at line 27 of file PluginLua.h.
cPluginLua::cPluginLua | ( | const AString & | a_PluginDirectory, |
cDeadlockDetect & | a_DeadlockDetect | ||
) |
Definition at line 38 of file PluginLua.cpp.
|
overridevirtual |
Definition at line 50 of file PluginLua.cpp.
bool cPluginLua::AddHookCallback | ( | int | a_HookType, |
cLuaState::cCallbackPtr && | a_Callback | ||
) |
Adds a Lua callback to be called for the specified hook.
Returns true if the hook was added successfully.
Definition at line 1160 of file PluginLua.cpp.
|
inline |
Call a Lua function residing in the plugin.
Definition at line 160 of file PluginLua.h.
int cPluginLua::CallFunctionFromForeignState | ( | const AString & | a_FunctionName, |
cLuaState & | a_ForeignState, | ||
int | a_ParamStart, | ||
int | a_ParamEnd | ||
) |
Calls a function in this plugin's LuaState with parameters copied over from a_ForeignState.
The values that the function returns are placed onto a_ForeignState. Returns the number of values returned, if successful, or negative number on failure.
Definition at line 1170 of file PluginLua.cpp.
|
inlineprotected |
Calls a hook that has the simple format - single bool return value specifying whether the chain should continue.
The advanced hook types that need more processing implement a similar loop manually instead. Returns true if any of hook calls wants to abort the hook (returned true), false if all hook calls returned false.
Definition at line 193 of file PluginLua.h.
bool cPluginLua::CanAddOldStyleHook | ( | int | a_HookType | ) |
Returns true if the plugin contains the function for the specified hook type, using the old-style registration (#121)
Definition at line 1053 of file PluginLua.cpp.
|
protected |
Removes all WebTabs currently registered for this plugin from the WebAdmin.
Definition at line 1204 of file PluginLua.cpp.
|
protected |
Releases all Lua references, notifies and removes all m_Resettables[] and closes the m_LuaState.
Definition at line 60 of file PluginLua.cpp.
|
static |
Returns the name of Lua function that should handle the specified hook type in the older (#121) API.
Definition at line 1083 of file PluginLua.cpp.
|
overridevirtual |
Loads and initializes the plugin.
Sets m_Status to psLoaded or psError accordingly. Returns true if the initialization succeeded, false otherwise.
Implements cPlugin.
Definition at line 84 of file PluginLua.cpp.
|
overridevirtual |
Calls the specified hook with the params given.
Returns the bool that the hook callback returns.
Implements cPlugin.
Definition at line 221 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 230 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 254 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 263 of file PluginLua.cpp.
Implements cPlugin.
Definition at line 272 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 296 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 305 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 314 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 323 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 332 of file PluginLua.cpp.
Implements cPlugin.
Definition at line 341 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 350 of file PluginLua.cpp.
|
overridevirtual |
Called as the last call into the plugin before it is unloaded.
Reimplemented from cPlugin.
Definition at line 198 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 359 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 528 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 368 of file PluginLua.cpp.
Implements cPlugin.
Definition at line 386 of file PluginLua.cpp.
Implements cPlugin.
Definition at line 377 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 688 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 395 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 419 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 460 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 501 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 510 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 519 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 537 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 561 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 570 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 579 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 588 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 597 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 606 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 732 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 615 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 624 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 642 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 652 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 633 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 661 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 670 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 679 of file PluginLua.cpp.
Implements cPlugin.
Definition at line 697 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 706 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 719 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 742 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 751 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 760 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 769 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 778 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 787 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 796 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 805 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 814 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 823 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 832 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 854 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 863 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 872 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 881 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 890 of file PluginLua.cpp.
Implements cPlugin.
Definition at line 914 of file PluginLua.cpp.
Implements cPlugin.
Definition at line 923 of file PluginLua.cpp.
Implements cPlugin.
Definition at line 932 of file PluginLua.cpp.
Implements cPlugin.
Definition at line 941 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 950 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 959 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 973 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 1002 of file PluginLua.cpp.
Implements cPlugin.
Definition at line 1011 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 1035 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 1044 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 212 of file PluginLua.cpp.
|
overridevirtual |
Unloads the plugin.
Sets m_Status to psDisabled. The default implementation removes the plugin's associations with cPluginManager, descendants should call it as well.
Reimplemented from cPlugin.
Definition at line 187 of file PluginLua.cpp.
|
protected |
The DeadlockDetect object to which the plugin's CS is tracked.
Definition at line 180 of file PluginLua.h.
|
protected |
Hooks that the plugin has registered.
Definition at line 177 of file PluginLua.h.
|
protected |
The plugin's Lua state.
Definition at line 174 of file PluginLua.h.