![]() |
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 | 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, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override |
virtual bool | OnPlayerBrokenBlock (cPlayer &a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) 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) override |
virtual bool | OnPlayerFishing (cPlayer &a_Player, cItems &a_Reward) 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, char a_BlockFace, char a_Status) override |
virtual bool | OnPlayerMoving (cPlayer &a_Player, const Vector3d &a_OldPosition, const Vector3d &a_NewPosition) 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, char 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, char 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, char 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, char 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, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override |
virtual bool | OnPluginMessage (cClientHandle &a_Client, const AString &a_Channel, const AString &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 |
![]() | |
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 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... | |
![]() | |
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... | |
![]() | |
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 | |
typedef cPlugin | super |
Definition at line 24 of file PluginLua.h.
|
protected |
Maps hook types into arrays of Lua function references to call for each hook type.
Definition at line 169 of file PluginLua.h.
|
protected |
Provides an array of Lua function references.
Definition at line 166 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 36 of file PluginLua.cpp.
|
overridevirtual |
Definition at line 48 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 1138 of file PluginLua.cpp.
|
inline |
Call a Lua function residing in the plugin.
Definition at line 159 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 1148 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 192 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 1032 of file PluginLua.cpp.
|
protected |
Removes all WebTabs currently registered for this plugin from the WebAdmin.
Definition at line 1182 of file PluginLua.cpp.
|
protected |
Releases all Lua references, notifies and removes all m_Resettables[] and closes the m_LuaState.
Definition at line 58 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 1062 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 82 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 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 677 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 459 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 499 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 508 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 517 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 526 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 550 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 559 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 568 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 577 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 586 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 595 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 604 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 613 of file PluginLua.cpp.
Implements cPlugin.
Definition at line 631 of file PluginLua.cpp.
Implements cPlugin.
Definition at line 641 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 622 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 650 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 659 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 668 of file PluginLua.cpp.
Implements cPlugin.
Definition at line 686 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 695 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 708 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 721 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 730 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 739 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 748 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 757 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 766 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 775 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 784 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 793 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 802 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 811 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 833 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 842 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 851 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 860 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 869 of file PluginLua.cpp.
Implements cPlugin.
Definition at line 893 of file PluginLua.cpp.
Implements cPlugin.
Definition at line 902 of file PluginLua.cpp.
Implements cPlugin.
Definition at line 911 of file PluginLua.cpp.
Implements cPlugin.
Definition at line 920 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 929 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 938 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 952 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 981 of file PluginLua.cpp.
Implements cPlugin.
Definition at line 990 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 1014 of file PluginLua.cpp.
|
overridevirtual |
Implements cPlugin.
Definition at line 1023 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 179 of file PluginLua.h.
|
protected |
Hooks that the plugin has registered.
Definition at line 176 of file PluginLua.h.
|
protected |
The plugin's Lua state.
Definition at line 173 of file PluginLua.h.