summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-07-04 15:54:39 +0200
committermadmaxoft <github@xoft.cz>2014-07-04 15:54:39 +0200
commitc7a5347cd63f9e39e9732ee4720423824fb41175 (patch)
tree962bb5d4db7e1964ecfb748bdf68d2c0069fcac8
parentMerge remote-tracking branch 'origin/HandleCommand' (diff)
downloadcuberite-c7a5347cd63f9e39e9732ee4720423824fb41175.tar
cuberite-c7a5347cd63f9e39e9732ee4720423824fb41175.tar.gz
cuberite-c7a5347cd63f9e39e9732ee4720423824fb41175.tar.bz2
cuberite-c7a5347cd63f9e39e9732ee4720423824fb41175.tar.lz
cuberite-c7a5347cd63f9e39e9732ee4720423824fb41175.tar.xz
cuberite-c7a5347cd63f9e39e9732ee4720423824fb41175.tar.zst
cuberite-c7a5347cd63f9e39e9732ee4720423824fb41175.zip
-rw-r--r--src/Bindings/PluginManager.cpp41
1 files changed, 34 insertions, 7 deletions
diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp
index 45bcc61cd..7e6502515 100644
--- a/src/Bindings/PluginManager.cpp
+++ b/src/Bindings/PluginManager.cpp
@@ -257,17 +257,44 @@ bool cPluginManager::CallHookBlockToPickups(
bool cPluginManager::CallHookChat(cPlayer * a_Player, AString & a_Message)
{
+ // Check if the message contains a command, execute it:
switch (HandleCommand(a_Player, a_Message, true))
{
- case crExecuted: return true;
- case crError: a_Player->SendMessageFailure(Printf("Something went wrong while executing command \"%s\"", a_Message.c_str())); return true;
- case crBlocked: return true; // The plugin that blocked the command probably wants to send a message to the player.
- case crNoPermission: a_Player->SendMessageFailure(Printf("Forbidden command; insufficient privileges: \"%s\"", a_Message.c_str())); return true;
- case crUnknownCommand: break;
+ case crExecuted:
+ {
+ // The command has executed successfully
+ return true;
+ }
+
+ case crBlocked:
+ {
+ // The command was blocked by a plugin using HOOK_EXECUTE_COMMAND
+ // The plugin has most likely sent a message to the player already
+ return true;
+ }
+
+ case crError:
+ {
+ // An error in the plugin has prevented the command from executing. Report the error to the player:
+ a_Player->SendMessageFailure(Printf("Something went wrong while executing command \"%s\"", a_Message.c_str()));
+ return true;
+ }
+
+ case crNoPermission:
+ {
+ // The player is not allowed to execute this command
+ a_Player->SendMessageFailure(Printf("Forbidden command; insufficient privileges: \"%s\"", a_Message.c_str()));
+ return true;
+ }
+
+ case crUnknownCommand:
+ {
+ // This was not a known command, keep processing as a message
+ break;
+ }
}
- // Check if it was a standard command (starts with a slash)
- // If it was, we know that it was completely unrecognised
+ // Check if the message is a command (starts with a slash). If it is, we know that it wasn't recognised:
if (!a_Message.empty() && (a_Message[0] == '/'))
{
AStringVector Split(StringSplit(a_Message, " "));