summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMat <mail@mathias.is>2020-03-19 20:06:25 +0100
committerGitHub <noreply@github.com>2020-03-19 20:06:25 +0100
commit646d3d6a2e6b05d2493a9e185d3229f43836deaf (patch)
treede16a6f106628f05985ed5e3812bda2d8320d28c /src
parentImprovements to knockback (#4504) (diff)
downloadcuberite-646d3d6a2e6b05d2493a9e185d3229f43836deaf.tar
cuberite-646d3d6a2e6b05d2493a9e185d3229f43836deaf.tar.gz
cuberite-646d3d6a2e6b05d2493a9e185d3229f43836deaf.tar.bz2
cuberite-646d3d6a2e6b05d2493a9e185d3229f43836deaf.tar.lz
cuberite-646d3d6a2e6b05d2493a9e185d3229f43836deaf.tar.xz
cuberite-646d3d6a2e6b05d2493a9e185d3229f43836deaf.tar.zst
cuberite-646d3d6a2e6b05d2493a9e185d3229f43836deaf.zip
Diffstat (limited to '')
-rw-r--r--src/BlockEntities/CommandBlockEntity.cpp26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/BlockEntities/CommandBlockEntity.cpp b/src/BlockEntities/CommandBlockEntity.cpp
index 98ef53b86..a1e4932ba 100644
--- a/src/BlockEntities/CommandBlockEntity.cpp
+++ b/src/BlockEntities/CommandBlockEntity.cpp
@@ -163,6 +163,11 @@ void cCommandBlockEntity::Execute()
return;
}
+ if (m_Command.empty())
+ {
+ return;
+ }
+
class CommandBlockOutCb :
public cCommandOutputCallback
{
@@ -175,21 +180,30 @@ void cCommandBlockEntity::Execute()
{
// Overwrite field
m_CmdBlock->SetLastOutput(cClientHandle::FormatChatPrefix(m_CmdBlock->GetWorld()->ShouldUseChatPrefixes(), "SUCCESS", cChatColor::Green, cChatColor::White) + a_Text);
+ m_CmdBlock->GetWorld()->BroadcastBlockEntity(m_CmdBlock->GetPos());
}
} CmdBlockOutCb(this);
+ AString RealCommand = m_Command;
+
+ // Remove leading slash if it exists, since console commands don't use them
+ if (RealCommand[0] == '/')
+ {
+ RealCommand = RealCommand.substr(1, RealCommand.length());
+ }
+
// Administrator commands are not executable by command blocks:
if (
- (m_Command != "stop") &&
- (m_Command != "restart") &&
- (m_Command != "kick") &&
- (m_Command != "ban") &&
- (m_Command != "ipban")
+ (RealCommand != "stop") &&
+ (RealCommand != "restart") &&
+ (RealCommand != "kick") &&
+ (RealCommand != "ban") &&
+ (RealCommand != "ipban")
)
{
cServer * Server = cRoot::Get()->GetServer();
LOGD("cCommandBlockEntity: Executing command %s", m_Command.c_str());
- Server->ExecuteConsoleCommand(m_Command, CmdBlockOutCb);
+ Server->ExecuteConsoleCommand(RealCommand, CmdBlockOutCb);
}
else
{