From cbb1eff17a085f57472f67cbe3682232fb3a4aeb Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sun, 10 May 2015 21:29:06 +0200 Subject: Added the EntireCommand parameter to HOOK_EXECUTE_COMMAND. Fixes #1996. --- MCServer/Plugins/APIDump/Hooks/OnExecuteCommand.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'MCServer/Plugins/APIDump/Hooks/OnExecuteCommand.lua') diff --git a/MCServer/Plugins/APIDump/Hooks/OnExecuteCommand.lua b/MCServer/Plugins/APIDump/Hooks/OnExecuteCommand.lua index dadc4e94f..d7a5d383d 100644 --- a/MCServer/Plugins/APIDump/Hooks/OnExecuteCommand.lua +++ b/MCServer/Plugins/APIDump/Hooks/OnExecuteCommand.lua @@ -16,7 +16,8 @@ return Params = { { Name = "Player", Type = "{{cPlayer}}", Notes = "For in-game commands, the player who has sent the message. For console commands, nil" }, - { Name = "Command", Type = "table of strings", Notes = "The command and its parameters, broken into a table by spaces" }, + { Name = "CommandSplit", Type = "array-table of strings", Notes = "The command and its parameters, broken into a table by spaces" }, + { Name = "EntireCommand", Type = "string", Notes = "The entire command as a single string" }, }, Returns = [[ If the plugin returns true, the command will be blocked and none of the remaining hook handlers will -- cgit v1.2.3 From 6c53abed23011423e95a30d2ad50bbe95aca365e Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sun, 10 May 2015 21:46:25 +0200 Subject: Call HOOK_EXECUTE_COMMAND even for unknown console commands. This allows plugins such as Aliases to intercept even unknown commands. --- MCServer/Plugins/APIDump/Hooks/OnExecuteCommand.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'MCServer/Plugins/APIDump/Hooks/OnExecuteCommand.lua') diff --git a/MCServer/Plugins/APIDump/Hooks/OnExecuteCommand.lua b/MCServer/Plugins/APIDump/Hooks/OnExecuteCommand.lua index d7a5d383d..d920a83ba 100644 --- a/MCServer/Plugins/APIDump/Hooks/OnExecuteCommand.lua +++ b/MCServer/Plugins/APIDump/Hooks/OnExecuteCommand.lua @@ -2,7 +2,10 @@ return { HOOK_EXECUTE_COMMAND = { - CalledWhen = "A player executes an in-game command, or the admin issues a console command. Note that built-in console commands are exempt to this hook - they are always performed and the hook is not called.", + CalledWhen = [[ + A player executes an in-game command, or the admin issues a console command. Note that built-in + console commands are exempt to this hook - they are always performed and the hook is not called. + ]], DefaultFnName = "OnExecuteCommand", -- also used as pagename Desc = [[ A plugin may implement a callback for this hook to intercept both in-game commands executed by the @@ -11,7 +14,12 @@ return server.

If the command is in-game, the first parameter to the hook function is the {{cPlayer|player}} who's - executing the command. If the command comes from the server console, the first parameter is nil. + executing the command. If the command comes from the server console, the first parameter is nil.

+

+ The server calls this hook even for unregistered (unknown) console commands. However, it doesn't call + the hook for unregistered in-game commands, simply because there's no way to distinguish between a + command and a chat message. If a plugin needs to intercept unknown in-game commands, it should use the + {{OnChat|HOOK_CHAT}} hook. ]], Params = { -- cgit v1.2.3 From dd10ffb63ad98cf2f4df2141a8fd64c21d414529 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sun, 10 May 2015 23:11:30 +0200 Subject: OnExecuteCommand hook can override the command result (crXXX). --- MCServer/Plugins/APIDump/Hooks/OnExecuteCommand.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'MCServer/Plugins/APIDump/Hooks/OnExecuteCommand.lua') diff --git a/MCServer/Plugins/APIDump/Hooks/OnExecuteCommand.lua b/MCServer/Plugins/APIDump/Hooks/OnExecuteCommand.lua index d920a83ba..79b7bb055 100644 --- a/MCServer/Plugins/APIDump/Hooks/OnExecuteCommand.lua +++ b/MCServer/Plugins/APIDump/Hooks/OnExecuteCommand.lua @@ -28,9 +28,11 @@ return { Name = "EntireCommand", Type = "string", Notes = "The entire command as a single string" }, }, Returns = [[ - If the plugin returns true, the command will be blocked and none of the remaining hook handlers will - be called. If the plugin returns false, MCServer calls all the remaining hook handlers and finally - the command will be executed. + If the plugin returns false, MCServer calls all the remaining hook handlers and finally the command + will be executed. If the plugin returns true, the none of the remaining hook handlers will be called. + In this case the plugin can return a second value, specifying whether what the command result should + be set to, one of the {{cPluginManager#CommandResult|CommandResult}} constants. If not + provided, the value defaults to crBlocked. ]], }, -- HOOK_EXECUTE_COMMAND } -- cgit v1.2.3 From f36b00f4d496cb90c8c77d0e6ae570502f3199ae Mon Sep 17 00:00:00 2001 From: Mattes D Date: Wed, 13 May 2015 18:31:01 +0200 Subject: All in-game commands go through the OnExecuteCommand hook. Everything that has a slash at the beginning, doesn't matter if it is a registered command or not. --- MCServer/Plugins/APIDump/Hooks/OnExecuteCommand.lua | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'MCServer/Plugins/APIDump/Hooks/OnExecuteCommand.lua') diff --git a/MCServer/Plugins/APIDump/Hooks/OnExecuteCommand.lua b/MCServer/Plugins/APIDump/Hooks/OnExecuteCommand.lua index 79b7bb055..db7eb97d1 100644 --- a/MCServer/Plugins/APIDump/Hooks/OnExecuteCommand.lua +++ b/MCServer/Plugins/APIDump/Hooks/OnExecuteCommand.lua @@ -16,10 +16,9 @@ return If the command is in-game, the first parameter to the hook function is the {{cPlayer|player}} who's executing the command. If the command comes from the server console, the first parameter is nil.

- The server calls this hook even for unregistered (unknown) console commands. However, it doesn't call - the hook for unregistered in-game commands, simply because there's no way to distinguish between a - command and a chat message. If a plugin needs to intercept unknown in-game commands, it should use the - {{OnChat|HOOK_CHAT}} hook. + The server calls this hook even for unregistered (unknown) console commands. It also calls the hook + for unknown in-game commands, as long as they begin with a slash ('/'). If a plugin needs to intercept + in-game chat messages not beginning with a slash, it should use the {{OnChat|HOOK_CHAT}} hook. ]], Params = { -- cgit v1.2.3