From 248ba1ea9f6826234535c2a777b3834fbe264e0d Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 29 Dec 2013 12:51:58 +0100 Subject: Added HOOK_PLUGINS_LOADED. This fixes #482. --- MCServer/Plugins/Debuggers/Debuggers.lua | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'MCServer/Plugins/Debuggers/Debuggers.lua') diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index c9a610f71..8f2fa3682 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -27,6 +27,7 @@ function Initialize(Plugin) cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_RIGHT_CLICKING_ENTITY, OnPlayerRightClickingEntity); cPluginManager.AddHook(cPluginManager.HOOK_WORLD_TICK, OnWorldTick); cPluginManager.AddHook(cPluginManager.HOOK_CHUNK_GENERATED, OnChunkGenerated); + cPluginManager.AddHook(cPluginManager.HOOK_PLUGINS_LOADED, OnPluginsLoaded); PM = cRoot:Get():GetPluginManager(); PM:BindCommand("/le", "debuggers", HandleListEntitiesCmd, "- Shows a list of all the loaded entities"); @@ -524,6 +525,14 @@ end +function OnPluginsLoaded() + LOG("All plugins loaded"); +end + + + + + function OnChunkGenerated(a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc) -- Get the topmost block coord: local Height = a_ChunkDesc:GetHeight(0, 0); -- cgit v1.2.3 From 84bf32f857f890ce50c82a2612fe1bfe072886c9 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 5 Jan 2014 15:46:45 +0100 Subject: Fixed cPluginManager:AddHook() binding. Fixes #401. Old formats are still accepted, for compatibility reasons. --- MCServer/Plugins/Debuggers/Debuggers.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'MCServer/Plugins/Debuggers/Debuggers.lua') diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index 8f2fa3682..c769edc3e 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -963,3 +963,22 @@ end + +-- Test the hook adding formats in #121 and #401 +local function DoNothing() +end + +LOG("Trying cPluginManager:AddHook()"); +cPluginManager:AddHook(cPluginManager.HOOK_CHAT, DoNothing); + +LOG("Trying cPluginManager.AddHook()"); +cPluginManager.AddHook(cPluginManager.HOOK_CHAT, DoNothing); + +LOG("Trying cPluginManager:Get():AddHook()"); +cPluginManager:Get():AddHook(cPluginManager.HOOK_CHAT, DoNothing); + +LOG("Trying cPluginManager:Get():AddHook(Plugin, Hook)"); +cPluginManager:Get():AddHook(cPluginManager:GetCurrentPlugin(), cPluginManager.HOOK_CHAT); + +LOG("Trying cPluginManager.AddHook(Plugin, Hook)"); +cPluginManager.AddHook(cPluginManager:GetCurrentPlugin(), cPluginManager.HOOK_CHAT); -- cgit v1.2.3 From e353f29d4ab5deec7ac8b3aac5f3f5c2b8fa56e9 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 7 Jan 2014 17:47:05 +0100 Subject: Plugin messages are received and handed to plugins. Note that MCS doesn't currently handle any channel registrations, this will come later on. --- MCServer/Plugins/Debuggers/Debuggers.lua | 35 +++++++++++--------------------- 1 file changed, 12 insertions(+), 23 deletions(-) (limited to 'MCServer/Plugins/Debuggers/Debuggers.lua') diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index c769edc3e..7b43b6c20 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -19,15 +19,16 @@ function Initialize(Plugin) cPluginManager.AddHook(cPluginManager.HOOK_TICK, OnTick2); --]] - cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_USING_BLOCK, OnPlayerUsingBlock); - cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_USING_ITEM, OnPlayerUsingItem); - cPluginManager.AddHook(cPluginManager.HOOK_TAKE_DAMAGE, OnTakeDamage); - cPluginManager.AddHook(cPluginManager.HOOK_TICK, OnTick); - cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChat); - cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_RIGHT_CLICKING_ENTITY, OnPlayerRightClickingEntity); - cPluginManager.AddHook(cPluginManager.HOOK_WORLD_TICK, OnWorldTick); - cPluginManager.AddHook(cPluginManager.HOOK_CHUNK_GENERATED, OnChunkGenerated); - cPluginManager.AddHook(cPluginManager.HOOK_PLUGINS_LOADED, OnPluginsLoaded); + cPluginManager:AddHook(cPluginManager.HOOK_PLAYER_USING_BLOCK, OnPlayerUsingBlock); + cPluginManager:AddHook(cPluginManager.HOOK_PLAYER_USING_ITEM, OnPlayerUsingItem); + cPluginManager:AddHook(cPluginManager.HOOK_TAKE_DAMAGE, OnTakeDamage); + cPluginManager:AddHook(cPluginManager.HOOK_TICK, OnTick); + cPluginManager:AddHook(cPluginManager.HOOK_CHAT, OnChat); + cPluginManager:AddHook(cPluginManager.HOOK_PLAYER_RIGHT_CLICKING_ENTITY, OnPlayerRightClickingEntity); + cPluginManager:AddHook(cPluginManager.HOOK_WORLD_TICK, OnWorldTick); + cPluginManager:AddHook(cPluginManager.HOOK_CHUNK_GENERATED, OnChunkGenerated); + cPluginManager:AddHook(cPluginManager.HOOK_PLUGINS_LOADED, OnPluginsLoaded); + cPluginManager:AddHook(cPluginManager.HOOK_PLUGIN_MESSAGE, OnPluginMessage); PM = cRoot:Get():GetPluginManager(); PM:BindCommand("/le", "debuggers", HandleListEntitiesCmd, "- Shows a list of all the loaded entities"); @@ -541,7 +542,6 @@ function OnChunkGenerated(a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc) a_ChunkDesc:SetBlockTypeMeta(0, Height + 1, 0, E_BLOCK_SIGN_POST, 0); local BlockEntity = a_ChunkDesc:GetBlockEntity(0, Height + 1, 0); if (BlockEntity ~= nil) then - LOG("Setting sign lines..."); local SignEntity = tolua.cast(BlockEntity, "cSignEntity"); SignEntity:SetLines("Chunk:", tonumber(a_ChunkX) .. ", " .. tonumber(a_ChunkZ), "", "(Debuggers)"); end @@ -964,21 +964,10 @@ end --- Test the hook adding formats in #121 and #401 -local function DoNothing() +function OnPluginMessage(a_Client, a_Channel, a_Message) + LOGINFO("Received a plugin message from client " .. a_Client:GetUsername() .. ": channel '" .. a_Channel .. "', message '" .. a_Message .. "'"); end -LOG("Trying cPluginManager:AddHook()"); -cPluginManager:AddHook(cPluginManager.HOOK_CHAT, DoNothing); -LOG("Trying cPluginManager.AddHook()"); -cPluginManager.AddHook(cPluginManager.HOOK_CHAT, DoNothing); -LOG("Trying cPluginManager:Get():AddHook()"); -cPluginManager:Get():AddHook(cPluginManager.HOOK_CHAT, DoNothing); -LOG("Trying cPluginManager:Get():AddHook(Plugin, Hook)"); -cPluginManager:Get():AddHook(cPluginManager:GetCurrentPlugin(), cPluginManager.HOOK_CHAT); - -LOG("Trying cPluginManager.AddHook(Plugin, Hook)"); -cPluginManager.AddHook(cPluginManager:GetCurrentPlugin(), cPluginManager.HOOK_CHAT); -- cgit v1.2.3 From 00af5d4d6e26ad0d48085d7204a3b8d42b34edac Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 9 Jan 2014 14:26:44 +0100 Subject: Debuggers: Test code for WECUI plugin messaging. --- MCServer/Plugins/Debuggers/Debuggers.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'MCServer/Plugins/Debuggers/Debuggers.lua') diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index 7b43b6c20..8512fbd5f 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -966,6 +966,23 @@ end function OnPluginMessage(a_Client, a_Channel, a_Message) LOGINFO("Received a plugin message from client " .. a_Client:GetUsername() .. ": channel '" .. a_Channel .. "', message '" .. a_Message .. "'"); + + if (a_Channel == "REGISTER") then + if (a_Message:find("WECUI")) then + -- The client has WorldEditCUI mod installed, test the comm by sending a few WECUI messages: + --[[ + WECUI messages have the following generic format: + | + If shape is p (cuboid selection), the params are sent individually for each corner click and have the following format: + |||| + point-index is 0 or 1 (lclk / rclk) + volume is the 3D volume of the current cuboid selected (all three coords' deltas multiplied), including the edge blocks; -1 if N/A + --]] + -- Select a 51 * 51 * 51 block cuboid: + a_Client:SendPluginMessage("WECUI", "p|0|50|50|50|-1"); + a_Client:SendPluginMessage("WECUI", "p|1|100|100|100|132651"); -- 132651 = 51 * 51 * 51 + end + end end -- cgit v1.2.3