cPluginManager::CommandResult cPluginManager::HandleCommand(cPlayer & a_Player, const AString & a_Command, bool a_ShouldCheckPermissions) { AStringVector Split(StringSplit(a_Command, " ")); if (Split.empty()) { return crUnknownCommand; } CommandMap::iterator cmd = m_Commands.find(Split[0]); 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; } // Ask plugins first if a command is okay to execute the command: CommandResult Result = crBlocked; if (CallHookExecuteCommand(&a_Player, Split, a_Command, Result)) { 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 ( a_ShouldCheckPermissions && !cmd->second.m_Permission.empty() && !a_Player.HasPermission(cmd->second.m_Permission) ) { LOGINFO("Player %s tried to execute forbidden command: \"%s\"", a_Player.GetName().c_str(), Split[0].c_str()); return crNoPermission; } ASSERT(cmd->second.m_Handler != nullptr); if (!cmd->second.m_Handler->ExecuteCommand(Split, &a_Player, a_Command, nullptr)) { return crError; } return crExecuted; }