diff options
author | STRWarrior <STRWarrior@users.noreply.github.com> | 2014-08-30 22:42:38 +0200 |
---|---|---|
committer | STRWarrior <STRWarrior@users.noreply.github.com> | 2014-08-30 22:42:38 +0200 |
commit | 9f321e29cf50c5cdd828fa1bbce1de2f0cbbc58e (patch) | |
tree | a6ad2990fdaff104c3663a8655be26ad55dc1ccc /src/BlockEntities | |
parent | WSSAnvil: Removed leftover debugging code. (diff) | |
parent | Fixed style. (diff) | |
download | cuberite-9f321e29cf50c5cdd828fa1bbce1de2f0cbbc58e.tar cuberite-9f321e29cf50c5cdd828fa1bbce1de2f0cbbc58e.tar.gz cuberite-9f321e29cf50c5cdd828fa1bbce1de2f0cbbc58e.tar.bz2 cuberite-9f321e29cf50c5cdd828fa1bbce1de2f0cbbc58e.tar.lz cuberite-9f321e29cf50c5cdd828fa1bbce1de2f0cbbc58e.tar.xz cuberite-9f321e29cf50c5cdd828fa1bbce1de2f0cbbc58e.tar.zst cuberite-9f321e29cf50c5cdd828fa1bbce1de2f0cbbc58e.zip |
Diffstat (limited to 'src/BlockEntities')
-rw-r--r-- | src/BlockEntities/CommandBlockEntity.cpp | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/BlockEntities/CommandBlockEntity.cpp b/src/BlockEntities/CommandBlockEntity.cpp index 45f8a3e4d..dd0858378 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,28 @@ 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); + // Administrator commands are not executable by command blocks: + if ( + (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; |