From 99876ea4bae68af856e1b7a231b180cdb1ffef32 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Thu, 21 Feb 2013 13:47:01 +0000 Subject: Added HOOK_EXECUTE_COMMAND for intercepting executed commands and console commands. Note that built-in console commands are exempt to this hook - they are always performed and the hook is not called. Also note that, for reasons unknown, the HookNotify plugin doesn't list the callback arguments. git-svn-id: http://mc-server.googlecode.com/svn/trunk@1221 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- MCServer/Plugins/HookNotify/HookNotify.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/HookNotify/HookNotify.lua b/MCServer/Plugins/HookNotify/HookNotify.lua index 92cc2e059..ed463c5ca 100644 --- a/MCServer/Plugins/HookNotify/HookNotify.lua +++ b/MCServer/Plugins/HookNotify/HookNotify.lua @@ -23,6 +23,7 @@ function Initialize(Plugin) PluginManager:AddHook(Plugin, cPluginManager.HOOK_COLLECTING_PICKUP); PluginManager:AddHook(Plugin, cPluginManager.HOOK_CRAFTING_NO_RECIPE); PluginManager:AddHook(Plugin, cPluginManager.HOOK_DISCONNECT); + PluginManager:AddHook(Plugin, cPluginManager.HOOK_EXECUTE_COMMAND); PluginManager:AddHook(Plugin, cPluginManager.HOOK_HANDSHAKE); PluginManager:AddHook(Plugin, cPluginManager.HOOK_KILLING); PluginManager:AddHook(Plugin, cPluginManager.HOOK_LOGIN); @@ -174,6 +175,21 @@ end +function OnExecuteCommand(...) + LogHook("OnExecuteCommand", unpack(arg)); + + -- For some reason logging doesn't work for this callback, so list some stuff manually to verify: + LOG("arg1 type: " .. type(arg[1])); + if (arg[1] ~= nil) then + LOG("Player name: " .. arg[1]:GetName()); + end + LOG("Command: " .. arg[2][1]); +end + + + + + function OnHandshake(...) LogHook("OnHandshake", unpack(arg)); end -- cgit v1.2.3