summaryrefslogtreecommitdiffstats
path: root/source/PluginManager.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-02-21 14:47:01 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-02-21 14:47:01 +0100
commit99876ea4bae68af856e1b7a231b180cdb1ffef32 (patch)
treed78bb997a9536709d9d2c31f09afaf1b153b81e7 /source/PluginManager.cpp
parentCore: Players console command now shows players' IP addresses (patch contributed by STR_Warrior) (diff)
downloadcuberite-99876ea4bae68af856e1b7a231b180cdb1ffef32.tar
cuberite-99876ea4bae68af856e1b7a231b180cdb1ffef32.tar.gz
cuberite-99876ea4bae68af856e1b7a231b180cdb1ffef32.tar.bz2
cuberite-99876ea4bae68af856e1b7a231b180cdb1ffef32.tar.lz
cuberite-99876ea4bae68af856e1b7a231b180cdb1ffef32.tar.xz
cuberite-99876ea4bae68af856e1b7a231b180cdb1ffef32.tar.zst
cuberite-99876ea4bae68af856e1b7a231b180cdb1ffef32.zip
Diffstat (limited to '')
-rw-r--r--source/PluginManager.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/source/PluginManager.cpp b/source/PluginManager.cpp
index 014cf719f..dc724b966 100644
--- a/source/PluginManager.cpp
+++ b/source/PluginManager.cpp
@@ -403,6 +403,27 @@ bool cPluginManager::CallHookDisconnect(cPlayer * a_Player, const AString & a_Re
+bool cPluginManager::CallHookExecuteCommand(cPlayer * a_Player, const AStringVector & a_Split)
+{
+ HookMap::iterator Plugins = m_Hooks.find(HOOK_EXECUTE_COMMAND);
+ if (Plugins == m_Hooks.end())
+ {
+ return false;
+ }
+ for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
+ {
+ if ((*itr)->OnExecuteCommand(a_Player, a_Split))
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+
+
+
+
bool cPluginManager::CallHookHandshake(cClientHandle * a_ClientHandle, const AString & a_Username)
{
HookMap::iterator Plugins = m_Hooks.find(HOOK_HANDSHAKE);
@@ -966,6 +987,13 @@ bool cPluginManager::HandleCommand(cPlayer * a_Player, const AString & a_Command
return false;
}
+ // Ask plugins first if a command is okay to execute the command:
+ if (CallHookExecuteCommand(a_Player, Split))
+ {
+ 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 false;
+ }
+
if (
a_ShouldCheckPermissions &&
!cmd->second.m_Permission.empty() &&
@@ -1282,6 +1310,13 @@ bool cPluginManager::ExecuteConsoleCommand(const AStringVector & a_Split)
return false;
}
+ // Ask plugins first if a command is okay to execute the console command:
+ if (CallHookExecuteCommand(NULL, a_Split))
+ {
+ LOGINFO("Command \"%s\" was stopped by the HOOK_EXECUTE_COMMAND hook", a_Split[0].c_str());
+ return false;
+ }
+
return cmd->second.m_Plugin->HandleConsoleCommand(a_Split);
}