diff options
author | Mattes D <github@xoft.cz> | 2015-05-11 10:39:45 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2015-05-11 10:39:45 +0200 |
commit | 7d66162e3c339e82d56e5144d466cab97eca82ab (patch) | |
tree | 5f3f1a00f704c7def6fc18b98c296e964f218815 /src/Bindings/PluginManager.cpp | |
parent | Merge pull request #1977 from mc-server/warnings (diff) | |
parent | APIDump: Added linkification to hook return values. (diff) | |
download | cuberite-7d66162e3c339e82d56e5144d466cab97eca82ab.tar cuberite-7d66162e3c339e82d56e5144d466cab97eca82ab.tar.gz cuberite-7d66162e3c339e82d56e5144d466cab97eca82ab.tar.bz2 cuberite-7d66162e3c339e82d56e5144d466cab97eca82ab.tar.lz cuberite-7d66162e3c339e82d56e5144d466cab97eca82ab.tar.xz cuberite-7d66162e3c339e82d56e5144d466cab97eca82ab.tar.zst cuberite-7d66162e3c339e82d56e5144d466cab97eca82ab.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Bindings/PluginManager.cpp | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index 003996802..15bea22bd 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -525,14 +525,14 @@ bool cPluginManager::CallHookEntityTeleport(cEntity & a_Entity, const Vector3d & -bool cPluginManager::CallHookExecuteCommand(cPlayer * a_Player, const AStringVector & a_Split) +bool cPluginManager::CallHookExecuteCommand(cPlayer * a_Player, const AStringVector & a_Split, const AString & a_EntireCommand, CommandResult & a_Result) { FIND_HOOK(HOOK_EXECUTE_COMMAND); VERIFY_HOOK; for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { - if ((*itr)->OnExecuteCommand(a_Player, a_Split)) + if ((*itr)->OnExecuteCommand(a_Player, a_Split, a_EntireCommand, a_Result)) { return true; } @@ -1449,10 +1449,14 @@ cPluginManager::CommandResult cPluginManager::HandleCommand(cPlayer & a_Player, } // Ask plugins first if a command is okay to execute the command: - if (CallHookExecuteCommand(&a_Player, Split)) + CommandResult Result = crBlocked; + if (CallHookExecuteCommand(&a_Player, Split, a_Command, Result)) { - LOGINFO("Player %s tried executing command \"%s\" that was stopped by the HOOK_EXECUTE_COMMAND hook", a_Player.GetName().c_str(), Split[0].c_str()); - return crBlocked; + if (Result == crBlocked) + { + LOGINFO("Player %s tried executing command \"%s\" that was stopped by the HOOK_EXECUTE_COMMAND hook", a_Player.GetName().c_str(), Split[0].c_str()); + } + return Result; } if ( @@ -1750,7 +1754,10 @@ bool cPluginManager::ExecuteConsoleCommand(const AStringVector & a_Split, cComma if (cmd == m_ConsoleCommands.end()) { // Command not found - return false; + // Still notify the plugins (so that plugins such as Aliases can intercept unknown commands). + CommandResult res = crBlocked; + CallHookExecuteCommand(nullptr, a_Split, a_Command, res); + return (res == crExecuted); } if (cmd->second.m_Plugin == nullptr) @@ -1760,10 +1767,10 @@ bool cPluginManager::ExecuteConsoleCommand(const AStringVector & a_Split, cComma } // Ask plugins first if a command is okay to execute the console command: - if (CallHookExecuteCommand(nullptr, a_Split)) + CommandResult res = crBlocked; + if (CallHookExecuteCommand(nullptr, a_Split, a_Command, res)) { - a_Output.Out("Command \"%s\" was stopped by the HOOK_EXECUTE_COMMAND hook", a_Split[0].c_str()); - return false; + return (res == crExecuted); } return cmd->second.m_Plugin->HandleConsoleCommand(a_Split, a_Output, a_Command); |