Merge pull request #2007 from mc-server/AllCommandsThroughHook
All in-game commands go through the OnExecuteCommand hook.
This commit is contained in:
commit
06506da0b1
@ -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.</p>
|
||||
<p>
|
||||
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 =
|
||||
{
|
||||
|
@ -1445,6 +1445,13 @@ cPluginManager::CommandResult cPluginManager::HandleCommand(cPlayer & a_Player,
|
||||
if (cmd == m_Commands.end())
|
||||
{
|
||||
// Command not found
|
||||
// If it started with a slash, ask the plugins if they still want to handle it:
|
||||
if (!a_Command.empty() && (a_Command[0] == '/'))
|
||||
{
|
||||
CommandResult Result = crUnknownCommand;
|
||||
CallHookExecuteCommand(&a_Player, Split, a_Command, Result);
|
||||
return Result;
|
||||
}
|
||||
return crUnknownCommand;
|
||||
}
|
||||
|
||||
|
@ -1473,7 +1473,7 @@ void cClientHandle::HandleChat(const AString & a_Message)
|
||||
Color.clear();
|
||||
}
|
||||
Msg.AddTextPart(AString("<") + m_Player->GetName() + "> ", Color);
|
||||
Msg.ParseText(a_Message);
|
||||
Msg.ParseText(Message);
|
||||
Msg.UnderlineUrls();
|
||||
m_Player->GetWorld()->BroadcastChat(Msg);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user