summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-08-29 14:41:50 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-08-29 14:41:50 +0200
commitfca5a01145f78a4ae517da6c19ee61ab54574e82 (patch)
treef4146dce0ba04016159c6915b6b847494312dfd9
parentMerge branch 'master' of https://github.com/mc-server/MCServer (diff)
downloadcuberite-fca5a01145f78a4ae517da6c19ee61ab54574e82.tar
cuberite-fca5a01145f78a4ae517da6c19ee61ab54574e82.tar.gz
cuberite-fca5a01145f78a4ae517da6c19ee61ab54574e82.tar.bz2
cuberite-fca5a01145f78a4ae517da6c19ee61ab54574e82.tar.lz
cuberite-fca5a01145f78a4ae517da6c19ee61ab54574e82.tar.xz
cuberite-fca5a01145f78a4ae517da6c19ee61ab54574e82.tar.zst
cuberite-fca5a01145f78a4ae517da6c19ee61ab54574e82.zip
-rw-r--r--src/BlockEntities/CommandBlockEntity.cpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/BlockEntities/CommandBlockEntity.cpp b/src/BlockEntities/CommandBlockEntity.cpp
index 45f8a3e4d..fe2f5e60a 100644
--- a/src/BlockEntities/CommandBlockEntity.cpp
+++ b/src/BlockEntities/CommandBlockEntity.cpp
@@ -13,6 +13,7 @@
#include "../Root.h"
#include "../Server.h" // ExecuteConsoleCommand()
#include "../Chunk.h"
+#include "../ChatColor.h"
@@ -206,15 +207,27 @@ void cCommandBlockEntity::Execute()
virtual void Out(const AString & a_Text)
{
// Overwrite field
- m_CmdBlock->SetLastOutput(a_Text);
+ m_CmdBlock->SetLastOutput(cClientHandle::FormatChatPrefix(m_CmdBlock->GetWorld()->ShouldUseChatPrefixes(), "SUCCESS", cChatColor::Green, cChatColor::White) + a_Text);
}
} CmdBlockOutCb(this);
- LOGD("cCommandBlockEntity: Executing command %s", m_Command.c_str());
-
- cServer * Server = cRoot::Get()->GetServer();
-
- Server->ExecuteConsoleCommand(m_Command, CmdBlockOutCb);
+ if ( // Administrator commands are not executable by command blocks
+ (m_Command != "stop") &&
+ (m_Command != "restart") &&
+ (m_Command != "kick") &&
+ (m_Command != "ban") &&
+ (m_Command != "ipban")
+ )
+ {
+ cServer * Server = cRoot::Get()->GetServer();
+ LOGD("cCommandBlockEntity: Executing command %s", m_Command.c_str());
+ Server->ExecuteConsoleCommand(m_Command, CmdBlockOutCb);
+ }
+ else
+ {
+ SetLastOutput(cClientHandle::FormatChatPrefix(GetWorld()->ShouldUseChatPrefixes(), "FAILURE", cChatColor::Rose, cChatColor::White) + "Adminstration commands can not be executed");
+ LOGD("cCommandBlockEntity: Prevented execution of administration command %s", m_Command.c_str());
+ }
// TODO 2014-01-18 xdot: Update the signal strength.
m_Result = 0;