diff options
author | Howaner <franzi.moos@googlemail.com> | 2014-09-02 20:03:42 +0200 |
---|---|---|
committer | Howaner <franzi.moos@googlemail.com> | 2014-09-02 20:03:42 +0200 |
commit | d3b8100a7b84a465ca52238d459bb10d32940c46 (patch) | |
tree | 2c272ec985b9228ef2e4892aeeabefa54786d215 /src/BlockEntities | |
parent | Removed SexyMotd link (diff) | |
parent | Re-added alternate spellings of darkgraywool. (diff) | |
download | cuberite-d3b8100a7b84a465ca52238d459bb10d32940c46.tar cuberite-d3b8100a7b84a465ca52238d459bb10d32940c46.tar.gz cuberite-d3b8100a7b84a465ca52238d459bb10d32940c46.tar.bz2 cuberite-d3b8100a7b84a465ca52238d459bb10d32940c46.tar.lz cuberite-d3b8100a7b84a465ca52238d459bb10d32940c46.tar.xz cuberite-d3b8100a7b84a465ca52238d459bb10d32940c46.tar.zst cuberite-d3b8100a7b84a465ca52238d459bb10d32940c46.zip |
Diffstat (limited to '')
-rw-r--r-- | src/BlockEntities/CommandBlockEntity.cpp | 35 | ||||
-rw-r--r-- | src/BlockEntities/FurnaceEntity.h | 2 |
2 files changed, 25 insertions, 12 deletions
diff --git a/src/BlockEntities/CommandBlockEntity.cpp b/src/BlockEntities/CommandBlockEntity.cpp index 45f8a3e4d..20702a9ac 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" @@ -187,12 +188,11 @@ void cCommandBlockEntity::SaveToJson(Json::Value & a_Value) void cCommandBlockEntity::Execute() { - if (m_World != NULL) + ASSERT(m_World != NULL); // Execute should not be called before the command block is attached to a world + + if (!m_World->AreCommandBlocksEnabled()) { - if (!m_World->AreCommandBlocksEnabled()) - { - return; - } + return; } class CommandBlockOutCb : @@ -206,15 +206,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; diff --git a/src/BlockEntities/FurnaceEntity.h b/src/BlockEntities/FurnaceEntity.h index 4f935a74b..cf1a755e0 100644 --- a/src/BlockEntities/FurnaceEntity.h +++ b/src/BlockEntities/FurnaceEntity.h @@ -105,7 +105,7 @@ protected: NIBBLETYPE m_BlockMeta; /// The recipe for the current input slot - const cFurnaceRecipe::Recipe * m_CurrentRecipe; + const cFurnaceRecipe::cRecipe * m_CurrentRecipe; /// The item that is being smelted cItem m_LastInput; |